[英]Clear mailboxes using Exchange Management Shell based on AD Logon Name (SAMAccountName?)
I have a CSV containing 150 - 200 AD logon names (SAMAccountNames?) and I need to loop through each user and clear their mailboxes. 我有一个包含150-200个AD登录名(SAMAccountNames?)的CSV,我需要遍历每个用户并清除其邮箱。
I can do that using this command 我可以使用此命令
Search-Mailbox -Identity "<MailboxOrMailUserIdParameter>" -DeleteContent -force
But the issue is that I need to be able to use the AD logon names, as I don't have the Identity? 但是问题是我需要能够使用AD登录名,因为我没有身份?
If you are importing the SamAccountName and you used that to create each alias for your mailboxes, then I would do something like this: 如果要导入SamAccountName,并用它来为邮箱创建每个别名,那么我将执行以下操作:
$names = get-content C:\path.of.csv
foreach($name in $names){
search-mailbox -identity $name -deletecontent -force
}
If your logon names do not match the alias of the mailbox, you need to figure out what attribute you used to populate that field. 如果您的登录名与邮箱的别名不匹配,则需要确定用于填充该字段的属性。 Then, you can use the same foreach loop to iterate through your AD objects to find the right attribute.
然后,您可以使用相同的foreach循环遍历AD对象以找到正确的属性。 Export that list and then try the search-mailbox using that.
导出该列表,然后使用该列表尝试搜索邮箱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.