It is important to understand that if your Azure AD is synced with your on-premise Active Directory then any changes made in Azure AD for users will b
It is important to understand that if your Azure AD is synced with your on-premise Active Directory then any changes made in Azure AD for users will be overwritten by the Active Directory object. Changes to users in Azure AD should only be made for ‘Cloud Only” users.
First we want to know if any of our users do not have a first or last name, why do we wan to know this? because a first name and last name are required to set a Display Name:
Get-AzureADUser | Where {$_.Surname -eq $null -and $_.GivenName -eq $null -and $_.UserType -eq "Member"} | Select UserPrincipalName, DisplayName
Setting User Display Name
$Users = Get-AzureADUser | Where {$_.UserType -eq "Member"} foreach ($user in $users) { if ($user.DirSyncEnabled) { write-host $user.UserPrincipalName is synced with On-Premises AD. Ignored in this script" - ForegroundColor Yellow } else { $NewDisplayName = $user.GivenName + " " + $User.SurName Write-host $User.UserPrincipalName " will be named $NewDisplayName" - ForegroundColor Green Set-AzureADUser -ObjectId $user.ObjectId -DisplayName $NewDisplayName }}
COMMENTS