PowerShell - Update AzureAD User Information
Go to solution
Solved by JTPOTATO,
So we got there in the end
聽
After running through a few edits here and there, and clearing it up a little, the below successfully works to update Azure Information automatically (So long as the details in the CSV are correct)
聽
#Connect to Azure AD - Make sure you sign in with an admin account Connect-AzureAD # Get CSV content $CSVrecords = Import-Csv "C:\Book2.csv" -Delimiter "," # Create arrays for skipped and failed users $SkippedUsers = @() $FailedUsers = @() # Loop trough CSV records foreach ($CSVrecord in $CSVrecords) { $upn = $CSVrecord.UserPrincipalName $user = Get-AzureADUser -Filter "userPrincipalName eq '$upn'" if ($user) { try{ #This will update Set-AzureADUser -Company $CSVrecord.Company -Country $CSVrecord.Country -Department $CSVrecord.Department -JobTitle $CSVrecord.Title Set-AzureADUserManager -ObjectId $CSVrecord.ObjectID -RefObjectId $CSVrecord.ManagerID } catch { $FailedUsers += $upnC Write-Warning "$upn user found, but FAILED to update." } } else { Write-Warning "$upn not found, skipped" $SkippedUsers += $upn } } # Array skipped users # $SkippedUsers # Array failed users # $FailedUsers
聽
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now