There is a requirement: the user has some mail groups do not want, want to delete, he himself tidied up the mail group of the Chinese name and Mail Group e-mail address, can be easily processed by a command.
The operation is very simple, you can look at the code comments
#导入一个csv, file, CSV file requires the first line to write mail, each of the following lines is an e-mail address import-csv c:\333.csv|foreach{$mail =$_.mail Set Variable, Get distinguishedname$zumingxxxx = (get-adgroup-properties mail-filter {mail-eq $mail}) for this group of mail addresses. distinguishedname# Display group name, prevent Misoperation Echo $zumingxxxx # Move security group or mail group to a specific OU move-adobject-identity $zumingxxxx-targetpath < #被移动的地址 #>-server bj-wtlad01# or you can choose to remove directly with the Force parameter, but this is not recommended, and the operation fails. #remove-adgroup $zumingxxxx}
This article is from the "Nine uncle-Microsoft Private Cloud" blog, please make sure to keep this source http://jiushu.blog.51cto.com/972756/1709873
Bulk Move/delete security groups/mail groups