Clear user information in Microsoft 365 Admin Center

Rohit 0 Reputation points

I am trying below PS script but information is not cleared in Managed Contact Information (Microsoft 365 Admin Center) for specific user.

Connect to Microsoft Graph


Get the user by UserPrincipalName

$user = Get-MgUser -UserId $UserPrincipalName

Clear the desired user properties

$user.Department = $null

$user.OfficeLocation = $null

$user.StreetAddress = $null

$user.City = $null

$user.State = $null

$user.Country = $null

$user.PostalCode = $null

$user.MobilePhone = $null

$user.DisplayName = $null

$user.MailNickName = $null

$user.JobTitle = $null

$user.GivenName = $null

$user.BusinessPhones = $null

Update the user with the cleared properties

Update-MgUser -Id $user.Id -UserPrincipalName $user.UserPrincipalName -User $user

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
3,346 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,950 questions
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
1,854 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pauline Mbabu 5 Reputation points Microsoft Employee

    The SDK currently does not support nullifying Values. See this thread for reference

    As a workaround try the following: Invoke-MgGraphRequest -Method PATCH -Uri "{USER-ID}" -Body @{Department= $null} to nullify properties.

    1 person found this answer helpful.
    0 comments No comments