Azure AD Attributes

Handian Sudianto 5,486 Reputation points
2023-02-15T16:19:02.72+00:00

Hello, How we can change or remove mobile phone values for all AAD users?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,413 questions
{count} votes

Accepted answer
  1. Vinod Survase 4,751 Reputation points
    2023-02-17T06:23:22.5+00:00

    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.
    
    
    
    

1 additional answer

Sort by: Most helpful
  1. James Hamil 26,026 Reputation points Microsoft Employee
    2023-02-16T20:04:14.44+00:00

    Hi @Handian Sudianto , are you asking for individual changes or bulk? For individual changes you can follow this document. user-profile-properties-single-page-view

    Navigate to "Contact Information" and you can manually update this. Please let me know if you have any questions or need help with bulk operations.

    If this answer helped you please mark it as "Verified" so other users can reference it.

    Thank you,

    James


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.