Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Exchange-find mailbox users with different SamAccountName and Alias

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Some time ago, the company mailbox was migrated, which involved the comparison of new and old mailbox account information. To sort out the mailbox users who are different from SamAccountName and Alias, and make a separate comparison. Here is the command & script:

Command:

Get-Mailbox-ResultSize Unlimited | where {$_ .SamAccountName-ne $_ .Alias} script # load Exchange, AD module Import-Module ActivedirectoryAdd-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010-ErrorAction SilentlyContinue# acquires mailbox users with different SamAccountName and Alias $Mailbox = Get-Mailbox-ResultSize Unlimited | where {$_ .SamAccountName-ne $_ .Alias} | foreach {$_ .SamAccountName} # ready to output collection $GlobalExport = @ () # cycle mailbox user foreach ($user in $Mailbox) {$enableuser = Get-aduser-Identity $user |? {$_ .SamAccountName-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} # Export to CSV$GlobalExport | Export-Csv f:\ scripts\ Mailbox.csv-Encoding UTF8

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report