I need PowerShell script to update user's office location PowerShell script to update bulk user's office location in azure AD with csv file in azure AD with csv file

Mutaz Abdelmajeed 1 Reputation point

I need a PowerShell script to update the user's Office Location attribute Azure AD through a CSV file in bulk.

Thank you!


A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,223 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,135 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 100.1K Reputation points MVP

    Hi @Mutaz Abdelmajeed ,

    if your csv looks like this (for example Sample7users.csv):


    "testpeter@test.net","Home Office"
    "testpaul@test.net","Room 234"

    this PowerShell script should work (tested):

    Import-Csv ".\Sample7users.csv" -Delimiter "," -Encoding UTF8 | ForEach-Object {
        $user = Get-AzureADUser -Filter "userPrincipalName eq '$($_.upn)'"
        Set-AzureADUser -ObjectId $user.ObjectID -PhysicalDeliveryOfficeName "$($_.office)"

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)


    Andreas Baumgarten