Hi @Handian Sudianto ,
Please check below steps.
Disclaimer: Kindly test this script in test environments or dummy account first and then you can execute for production once the results are expected.
To change or remove the mobile phone values for all users in Azure Active Directory (AAD), you can use PowerShell or Microsoft Graph API to automate the process.
Connect to your AAD using PowerShell or authenticate to Microsoft Graph API using an access token.
Retrieve a list of all users in your AAD. You can use the "Get-AzureADUser" cmdlet in PowerShell or the "users" endpoint in Microsoft Graph API to do this.
Use a loop to update or remove the mobile phone values for each user in the list. You can use the "Set-AzureADUser" cmdlet in PowerShell or the "PATCH" method in Microsoft Graph API to update or remove the mobile phone values.
To remove the mobile phone values for all users in AAD using PowerShell, you can use the following script:
Connect-AzureAD
$users = Get-AzureADUser -All $true
foreach ($user in $users) {
Set-AzureADUser -ObjectId $user.ObjectId -Mobile $null
}
This will set the mobile phone values to null for all users in AAD.
To remove the mobile phone values for all users in AAD using Microsoft Graph API, you can send a "PATCH" request to the "users" endpoint with the following payload:
{
"mobilePhone": null
}
Here's an example of how to do this using the Microsoft Graph API in PowerShell:
$accessToken = "<your access token>"
$headers = @{
"Authorization" = "Bearer $($accessToken)"
"Content-Type" = "application/json"
}
$users = Invoke-RestMethod -Method Get -Uri "https://graph.microsoft.com/v1.0/users" -Headers $headers
foreach ($user in $users.value) {
$uri = "https://graph.microsoft.com/v1.0/users/$($user.id)"
$payload = @{
mobilePhone = $null
}
$body = ConvertTo-Json $payload
Invoke-RestMethod -Method Patch -Uri $uri -Headers $headers -Body $body
}
This will send a "PATCH" request to update the mobile phone values to null for all users in AAD using Microsoft Graph API.