How to add company name for a bulk of user in Azure AD

J-3804 1,601 Reputation points
2023-08-29T22:58:10.1033333+00:00

Hi team,

Could you please send me steps to add company name to all users ( 697 users) in azure AD.

Thank you for your help.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Yannic Graber 596 Reputation points MVP
    2023-08-30T07:09:06.12+00:00

    Hello Jennifer

    I understand you want to add the company name to ALL of your users in Azure Active Directory.
    Easiest will be using Powershell, for example the following script.

    #name your company name as desired
    $YourCompanyName = "CompanyName"
    
    # Install AzureAD module if needed
    Install-Module -Name AzureAD
    
    # Connect to Azure AD
    Connect-AzureAD
    
    # Get the list of all users
    $users = Get-AzureADUser -All $true
    
    # Loop through users and add company name
    foreach ($user in $users) {
        $updatedUser = $user | Set-AzureADUser -Company $YourCompanyName
        Write-Host "Company name added for user: $($updatedUser.UserPrincipalName)"
    }
    
    # Disconnect from Azure AD
    Disconnect-AzureAD
    

    Don't forget to fill $YourCompanyName at the beginning with your desired name.

    If this does help to solve your request, please "accept this as answer". This helps others to identify the solution and serves as a token of appreciation.

    Best Regard,
    Yannic

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Fabrizio De Siati 0 Reputation points
    2025-02-24T13:57:56.95+00:00

    Updated version

    # Definisci il nome della tua azienda
    $YourCompanyName = "XXXXXX"
    
    # Installa il modulo Microsoft Graph se non è già presente
    Install-Module -Name Microsoft.Graph -Scope CurrentUser -Force
    
    # Importa il modulo
    Import-Module Microsoft.Graph
    
    # Connetti a Microsoft Graph con i permessi richiesti
    Connect-MgGraph -Scopes "User.ReadWrite.All"
    
    # Ottieni la lista di tutti gli utenti
    $users = Get-MgUser -All
    
    # Loop attraverso gli utenti e aggiorna il nome della compagnia
    foreach ($user in $users) {
        Update-MgUser -UserId $user.Id -CompanyName $YourCompanyName
        Write-Host "Company name added for user: $($user.UserPrincipalName)"
    }
    
    # Disconnetti da Microsoft Graph
    Disconnect-MgGraph
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.