Forum Discussion

yturaner's avatar
yturaner
Copper Contributor
Dec 16, 2021

update user properties from a csv file

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 ?

  • somnio0505's avatar
    somnio0505
    Brass Contributor

    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

Resources