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
2023-10-25T07:49:22.4366667+00:00

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

Thank you!

Mutaz

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

1 answer

Sort by: Most helpful
  1. Andreas Baumgarten 122.1K Reputation points MVP Volunteer Moderator
    2023-10-25T08:33:13.5533333+00:00

    Hi @Mutaz Abdelmajeed ,

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

    CSVfileCopy

    upn,office
    "******@test.net","Home Office"
    "******@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)

    Regards

    Andreas Baumgarten


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.