Exchange 常用命令

  1. PowerShell 添加Exchange 管理单元
    • 将一个或多个 Windows PowerShell 管理单元添加到当前会话中。
      • Add-PSSnapIn -Name Microsoft.Exchange, Microsoft.Windows.AD
    • 添加所有已注册的管理单元
      • Get-PSSnapin -Registered | Add-PSSnapin -Passthru
  2. 新建邮箱
    • New-Mailbox -UserPrincipalName libai@hello02.com -Alias libai -Database “db1601” -Name 李白 -OrganizationalUnit “ou=信息化部,ou=国务院,ou=China,dc=hello02,dc=com” -Password (convertto-securestring Admin909217  -asplaintext -force) -FirstName bai -LastName li -DisplayName “李白” -ResetPasswordOnNextLogon $true
  3. 查询UserMailbox,User
    • Get-MailBox -Identity  LiBai
    • Get-Mailbox -Database  db1601 
    • Get-Mailbox  | where {$_.isvalid -eq $faluse}   查询禁用的邮箱
    • Get-mailbox  -OrganizationalUint   it  |  Disable-Mailbox  -Confirm:$false
    • Get-User | where-object {$_.RecipientType -eq “UserMailbox”}
    • Get-User | where-object {$_.RecipientType -eq “User”}
  4. 邮箱统计
    • Get-mailboxStatistics  -Identity  ‘UserName’ | fl
  5. 删除添加通讯组中的成员
    • Remove- DistributionGroupMember  -idetity it  -Member  libai
    • Add- DistributionGroupMember -identity it -Member  libai 
  6. 邮件追踪
    • Get-TransportService | Get-MessageTrackingLog -Sender:user01@contoso.com -Recipients:use02@contoso.com -Start “2017/4/11 09:00:00” -End “2017/4/13 09:00:00” -EventId deliver | Select Sender,Recipients,timestamp,eventid,messagesubject
  7. 删除误发的群邮件
    • Search-Mailbox -SearchQuery ‘From:user01@abc.com And Subject:”CCC”‘ -DeleteContent
    • Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery ‘Subject:”Download this file”‘ -DeleteContent
  8. 导出AD 禁用的用户

Get-ADUser  -Filter {Enabled -eq “False”} |select UserPrincipalName |Export-Csv C:\Disable.csv -encoding utf8