In den meisten Unternehmen werden die Attribute eines Benutzers im AD Objekt gut gepflegt, darunter natürlich:
- Telefon
- Mobiltelefon
Diese Attribute werden auch leicht mithilfe von AADConnect ins Azure AD synchronisiert.
Problem
Die Mobiltelefonnummer wird nicht in SharePoint angezeigt, obwohl diese im AD/AAD gepflegt ist.
Wenn man sich den User Profile Service vom SharePoint ansieht, wird man feststellen, dass die Mobilnummer fehlt. Hier eine gute Erklärung der Funktionsweise: https://blog.atwork.at/post/How-user-profile-sync-works-in-Office-365-services
Es gibt in SharePoint Online keine Sync Einstellungen wie man es aus der on-premises Welt kennt. Dort gab es z.B. AD Import. Microsoft selbst bestimmt wann und welche Attribute synchronisiert werden.
Anders als in der on-premises Welt, werden nur bestimmte Attribute von Microsoft aus dem AAD zum User Profile Service übertragen.
Auch Delve bezieht seine Informationen aus dem SharePoint User Profile Service.
Lösung
Ich habe ein Skript angepasst, das sowohl MFA unterstützt und die PnP PowerShell verwendet, um das Attribut MobilePhone vom AAD in das Attribut CellPhone (= Mobiltelefon) überträgt:
Hier auch auf GitHub: https://github.com/Hobmaier/Scripts/blob/master/Start-SyncAADToSPOPnP.ps1
# original based on this but with modifications to run locally without Azure and MFA capable https://tishenko.com/sync-mobile-phone-aad-spo-cell-phone-azure-automation/
Import-Module MSOnline -ErrorAction Stop
Import-Module SharePointPnPPowerShellOnline -ErrorAction Stop
# Automation Variables
$tenantName = Read-Host -Prompt "Please provide tenant domain"
$spoAdminUrl = "https://$tenantName-admin.sharepoint.com"
$overwriteExistingSPOUPAValue = $true
Try {
# Connect to AzureAD
Connect-MsolService
# Connect to SPO using PnP
$spoPnPConnection = Connect-PnPOnline -Url $spoAdminUrl -UseWebLogin -ReturnConnection
# Get all AzureAD Users
$AzureADUsers = Get-MsolUser -All
ForEach ($AzureADUser in $AzureADUsers) {
Write-Output "Working on user: $($AzureADUser.UserPrincipalName)"
if (!([string]::IsNullOrEmpty($AzureADUser.MobilePhone)))
{
# Check to see if SPO UserProfileProperty CellPhone differs from AzureAD User Property MobilePhone
if((Get-PnPUserProfileProperty -Account $AzureADUser.UserPrincipalName).UserProfileProperties.CellPhone -ne $AzureADUser.MobilePhone){
# Property differs, update with AzureAD value
# Check to see if we're to overwrite existing property value
if ($overwriteExistingSPOUPAValue -eq "True") {
Write-Output "Update CellPhone for $($AzureADUser.UserPrincipalName) using $($AzureADUser.MobilePhone)"
Set-PnPUserProfileProperty -Account $AzureADUser.UserPrincipalName -PropertyName CellPhone -Value $AzureADUser.MobilePhone
}
else{
# Not going to overwrite existing property value
Write-Output "Target SPO UPA CellPhone is not empty for $($AzureADUser.UserPrincipalName) and we're to preserve existing properties"
}
} else {
Write-Output "CellPhone no change"
}
}
}
}
Catch {
$exception = $_.Exception.Message
Write-Output "$($exception)"
}
Die Ausgabe sieht dann in etwa so aus:

Zusammenfassung
Mithilfe von diesem Skript kann man die Mobiltelefonnummer in den User Profile Service schreiben. Grundsätzlich ist es auch denkbar, damit weitere Attribute zu füllen oder das Skript per Job oder Azure Automation täglich laufen zu lassen.
Achtung: Wenn der Benutzer selbstständig eine Mobilnummer eingegeben hat, wird diese durch das Skript überschrieben. Die manuelle Eingabe kann verhindert werden, wenn das Attribut CellPhone im UserProfileService das unterbindet.
Wird z.B. über die Suche die Attribute für z.B. eine Telefonliste ausgelesen, dauert es noch bis die Suche die Änderung indiziert und die Inhalte angezeigt werden. Idealerweise 15 Minuten, es sollte aber nach einem Tag sichtbar sein.
Vielen Vielen Dank das hat sehr weitergeholfen! 😉
Hinweis: Nur das Modul “SharePointPnPPowerShellOnline” muss gegen den Nachfolger “PnP.PowerShell” getauscht werden.