十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
命令:
创新互联拥有一支富有激情的企业网站制作团队,在互联网网站建设行业深耕十余年,专业且经验丰富。十余年网站优化营销经验,我们已为数千家中小企业提供了网站设计制作、做网站解决方案,按需定制开发,设计满意,售后服务无忧。所有客户皆提供一年免费网站维护!
Get-Mailbox -ResultSize Unlimited | where {$_.SamAccountName -ne $_.Alias}
# 加载 Exchange、AD 模块
Import-Module Activedirectory
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue
# 获取SamAccountName和Alias不相同的邮箱用户
$Mailbox = Get-Mailbox -ResultSize Unlimited | where {$_.SamAccountName -ne $_.Alias} | foreach {$_.SamAccountName}
# 准备输出集合
$GlobalExport = @()
# 循环处理邮箱用户
foreach ($user in $Mailbox)
{
$enableuser = Get-aduser -Identity $user | ?{$_.Enable -eq "True"}
$Mail = Get-Mailbox -ResultSize Unlimited $enableuser.SamAccountName
$Obj = New-Object PSObject
$Obj | Add-Member NoteProperty -Name "SamAccountName" -Value $Mail.SamAccountName
$Obj | Add-Member NoteProperty -Name "Alias" -Value $Mail.Alias
$Obj | Add-Member NoteProperty -Name "PrimarySmtpAddress" -Value $Mail.PrimarySmtpAddress
$Obj | Add-Member NoteProperty -Name "UserPrincipalName" -Value $Mail.UserPrincipalName
}
# 导出输出到CSV
$GlobalExport | Export-Csv f:\scripts\Mailbox.csv -Encoding UTF8