update user properties from a csv file

New Contributor

Hello

 

Using Microsoft 365 Azure AD and need a script to update user properties from a csv file (attached file contains the fields needing updating)

 

How can I do this ?

1 Reply

Hi, @yturaner 

 

I just leave a simple script below, you need to change some variables for specify user and properties what you want to change.

 

$userData = Import-Csv "___________.csv"

 

foreach {$user in $userData)

{

    $aadUser = Get-AzureADUser -Filter 'userPrincipalName eq "$user.userPrincipalName"'
    Set-AzureADUser -ObjectId $aadUser.ObjectId -State $user.State

 

}

 

Thank you