简体   繁体   English

使用Exchange命令行管理程序基于AD登录名(SAMAccountName?)清除邮箱

[英]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.

相关问题 如何获取用户有权访问Exchange2010的所有共享邮箱的列表| 是Exchange命令行管理程序还是PowerShell? - How to get a list of all the Shared Mailboxes that a user have access to Exchange2010 | Exchange Management Shell or PowerShell? 使用Exchange命令行管理程序删除共享邮箱上所有禁用用户的完全访问权限 - Remove full access permissions of all disabled users on shared mailboxes with exchange management shell 使用CSV文件作为输入来运行交换管理Shell命令 - Using CSV files as input to run exchange management shell commands 将调用命令脚本块与交换管理 shell 一起使用 - Using invoke-command scriptblock with exchange management shell Exchange命令行管理程序默认Exchange Server - Exchange Management Shell Default Exchange Server 使用Exchange命令行管理程序将邮箱属性从Exchange 2010导出到CSV - Exporting Mailbox Attributes from Exchange 2010 to CSV using Exchange Management Shell 如何在AD中更改用户登录名后缀? - How to change User Logon Name Suffix in AD? AD samAccountname脚本错误 - AD samAccountname scripting error 从 AD 获取 SamAccountName - Get SamAccountName from AD 更正PowerShell脚本以显示具有Exchange邮箱的禁用AD用户帐户(非共享邮箱)及其大小(以兆字节为单位)吗? - Correcting PowerShell script to show Disabled AD user account (not shared mailboxes) with Exchange mailbox and its size in MBytes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM