PowerShell is King! Find misconfigured users in AD


special info Today I got a call from a customer that was working on a Office 365 Project. As part of the Project they wanted to change the Exchange Email Address Policies to filter on the Company Name for each user. Only problem was that some of the users had a blank or misspelled Company name…

rencontres seniors 03 Luckily, someone invented PowerShell so we started by pulling a list of all Company Names by running this command:

blog here visit homepage Get-ADUser -Filter * -Properties Company | Group Company | Select Name,Count

Visit This Link SNAGHTML13b8fb8d

visit this site The result was as expected… Too many company names. Misspelled Company Names and users with no company name specified at all…

this contact form SNAGHTML13bcd7b5

site de rencontre ado geneve To get a list of all users with a “blank” Company Name; Run the following command:

site de rencontre yvelines rencontre femme le blanc 36 Get-ADUser -Filter * -Properties Company | Where {$_.Company -match “^$”} | Select samaccountname


The result included a lot of service accounts and other stuff where the Company Name might not be super important. But we did find +100 accounts that needs a Company Name.


Changing the company names can of course be done by PowerShell too, but in this scenario we didn’t have any luck to automate the assignment of the different company names, but the overview helped them a lot…

+Ronni Pedersen

About Author

My name is Ronni Pedersen and I'm currently working as a Cloud Solution Architect at EG A/S in Denmark. My primary focus is Enterprise Client Management solutions, based on technologies like AzureAD, Intune, EMS and System Center Configuration Manager. I'm is also a Microsoft Certified Trainer and Microsoft MVP in Enterprise Mobility.

Leave A Reply