Scenario
You are using Exclaimer and you want to update the company details for a user using the Company attribute.
Resolution
You can edit the Company attribute within the Exchange admin center, or set the value using PowerShell.
Select an option below to view the related instructions:
To edit the value in Exchange Online:
- Visit admin.exchange.microsoft.com.
- In the menu sidebar, expand Recipients and select Mailboxes.
- Select the user's mailbox.
- Select Organization.
- In the details panel, select Manage Organization Information.
- Enter the company name in the Company field.
- Select Save.
To set the value using PowerShell:
-
Install the Microsoft Graph PowerShell module, if not already installed, by running the following command:
Install-Module Microsoft.Graph -Scope CurrentUser -
Connect to Microsoft Graph by running the following command:
Connect-MgGraph -Scopes "User.ReadWrite.All" -
Set the Company field by running the following command:
Update-MgUser -UserId <username> -CompanyName "New Company Name"
An example of a typical Company field.
Running the Script Using PowerShell ISE or Visual Studio Code
Step 1: Install PowerShell Core (if not already installed)
To download PowerShell Core:
- Go to the PowerShell GitHub releases page and download the latest stable release for your operating system.
- Follow the installation instructions provided on the GitHub page.
Step 2: Install PowerShell ISE or Visual Studio Code
To install and run Powershell or Visual Studio Code:
EITHER:
-
Search for PowerShell ISE in the start menu and select to launch.
NOTE: This option is for Windows only. Powershell is included with Windows.
OR
- Download Visual Studio Code from the official website and run the installation.
-
Open Visual Studio Code and open the Extensions view by selecting the square icon in the sidebar or pressing
Ctrl+Shift+X. - Search for PowerShell and select Install on the PowerShell extension by Microsoft.
Step 3: Install the Microsoft Graph PowerShell Module
To open PowerShell ISE or Visual Studio Code:
- Launch PowerShell ISE or open a new PowerShell terminal in Visual Studio Code.
-
Run the following command:
Install-Module Microsoft.Graph -Scope CurrentUser - If prompted to install the NuGet provider, type Y and press Enter.
-
If asked to install from an untrusted repository, type Y and press Enter.
Step 4: Connect to Microsoft Graph
To connect to your Entra ID (formerly Azure AD):
-
Run the following command:
Connect-MgGraph -Scopes "User.ReadWrite.All" - Enter your Entra ID admin credentials in the sign in window.
Step 5: Run the Script
To enter and run the script:
-
Copy the following script:
# Define the target domain and new company name
$targetDomain = "example.com"
$newCompanyName = "New Company Name"
# Get all users
$allUsers = Get-MgUser -All
# Filter users by email domain
$filteredUsers = $allUsers | Where-Object { $_.Mail -like "*@$targetDomain" }
# Iterate over each filtered user and update the company name
foreach ($user in $filteredUsers) {
$userId = $user.Id
Write-Output "Updating company name for user: $($user.UserPrincipalName)"
Update-MgUser -UserId $userId -CompanyName $newCompanyName
}
Write-Output "Company name updated successfully for all users with domain $targetDomain."
- Paste the script into a new script file in PowerShell ISE or Visual Studio Code.
- If using PowerShell ISE, select Run Script, indicated by a green Play icon, or press F5.
- If using Visual Studio Code, select Run, indicated by a green Play icon, or press F5.
-