Check Global Address List Compliance PowerShell

Check Global Address List Compliance PowerShell

Hello,

When migrating to Office 365 from various exotic messaging system, you usually hit the fact that Active Directory isn’t a reflect of the situation. Especially when you’re looking at the attributes that are used for building the global address list for Exchange Online and Skype Online.With PowerShell you can run a quick query to retrieve all your users, and then, group by each attribute to check where you have values that look the same and aren’t the same. This will also show you how many users have empty attributes. Then based on this, you can have some correction to run, like:

  • Standardize the case
  • Spell city/location/country always the same (e.g.: United Kindom/England/UK or New-York/New York)
  • Remove wrong values

Check Global Address List Compliance PowerShell

To achieve the audit part, you can use something like this, this is a really basic exemple that will get all the users in the current domain, but you can customize it to only target some OU, or a remote domain.

$Properties = 'Title','physicalDeliveryOfficeName','department','company','co','country'
$Users = Get-AdUser -Filter * -Properties $Properties

$Properties | ForEach-Object -Process {
    Write-Verbose -Message "Statistics for $_" -Verbose
    $Users | Group-Object -Property $_ -NoElement
}

Those lines are highly customisable, you can add/remove attributes as you see fit, just specify the LDAP name of the wanted attribute.

Check Global Address List Compliance PowerShell - Audit

Check Global Address List Compliance PowerShell – Audit

Check Global Address List Compliance PowerShell – Correction

As you can see, my lab is quite a mess, let’s try to clean this up a little:

Get-ADUser -Filter * -SearchBase 'OU=Users,OU=Star Wars,OU=Production,DC=D2K12R2,DC=local' | Set-ADUser -Company 'Star Wars'
Check Global Address List Compliance PowerShell - Check Correction

Check Global Address List Compliance PowerShell – Check Correction

As you can see, there are a few less empty users, and 86 users with “Star Wars” as a company.

I also scoped this second query only on the attribute I corrected.

Check Global Address List Compliance PowerShell – Hunt for Loners

Now, let’s try to find that user with “Company1” that need correction:

Get-ADUser -Filter {Company -eq 'Company1'}
Check Global Address List Compliance PowerShell - Hunt for loners

Check Global Address List Compliance PowerShell – Hunt for loners

Now you you can fix it to match your corporate naming policies.

Note : You can also use this for your Exchange management scope.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.