Are you trying to update the Azure Active Directory “CompanyName” field using Powershell? Perhaps you already have a script for user creation and need to start adding your companies name to that field in AzureAD.

In my case, we have a group called “Company1” that is used for our dynamic mailing list. If the user is part of that group, then they appear in the dynamic list. However, I was slightly disappointed to see that I can’t just use a command like Set-MsolUser -ObjectId -ExtensionName "CompanyName" -ExtensionValue "MyCompanyName" to set this attribute.

You may also see some guides that say you need to run Set-AzureADUserExtension -ObjectId -ExtensionName "CompanyName" -ExtensionValue "Company1". However, in my test, I recieved an error that said The term ‘Connect-AzureAD’ is not recognized as the name of a cmdlet, function, script file, or operable program.

If you are running in this same issue, here’s the solution.

Step 1: Check if AzureAD module is installed

Open Powershell as administrator and type:

Get-InstalledModule -Name "AzureAD"

If you receive an error like below, that means it’s not installed yet.

Step 2: Install AzureAD Module

To install the AzureAD module, run this command

Install-Module -Name AzureADPreview

An untrusted repository box will pop up. Click Yes to All

A few seconds later it will say completed.

You can now verify by running this command:

Get-InstalledModule -Name "AzureADPreview"

Step 3: Connect to AzureAD

Next, you need to connect to your Azure AD tenant using this command. A box will pop up asking you to enter your Office 365 credentials to validate the login.


Step 4: Update CompanyName field

Once connected to Azure, run this command to update. You can then log into your Azure Active Directory tenant and browse to the user account you updated to verify the field gets updated properly.

Set-AzureADUserExtension -ObjectId -ExtensionName "CompanyName" -ExtensionValue "Company1"

My Homelab Equipment

Here is some of the gear I use in my Homelab. I highly recommend each of them.

The full list of server components I use can be found on my Equipment List page.

Similar Posts

Leave a Reply

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