您好,登錄后才能下訂單哦!
命令:
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 = @()
# 循環(huán)處理郵箱用戶
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
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。