Remove-MgUserContact

What is Remove-MgUserContact?

Remove-MgUserContact is a Microsoft Graph PowerShell cmdlet used to delete personal Outlook contacts from a specific user’s mailbox. It removes contacts that exist in the user’s Contacts folder, not directory users or Entra ID objects.

🚀 Community Edition Released!

Try the M365Corner Microsoft 365 Reporting Tool — your DIY pack with 20+ out-of-the-box M365 reports for Users, Groups, and Teams.

Why Use Remove-MgUserContact?

Administrators and automation engineers use this cmdlet to:

  • Clean up outdated or duplicate mailbox contacts
  • Reverse bulk contact imports
  • Automate mailbox contact hygiene tasks
  • Remove migrated or incorrectly created contacts
  • Perform scripted cleanup during offboarding or migrations

Unlike tenant-level contact cmdlets, this operates only within a user’s mailbox.


Prerequisites

Before using this cmdlet, ensure:

  • Microsoft Graph PowerShell module is installed
  • You are connected to Microsoft Graph
  • Required permission scope is granted
  • Install-Module Microsoft.Graph -Scope CurrentUser
    Connect-MgGraph -Scopes "Contacts.ReadWrite"
                                                

How to Use Remove-MgUserContact?

The cmdlet requires the UserId (UPN or User ID) and the ContactId of the contact to delete.

Basic syntax:

Remove-MgUserContact -UserId  <String>-ContactId <String>

You can obtain the ContactId using Get-MgUserContact before removal.


Remove-MgUserContact Examples

Remove a Specific Contact for a User

Remove-MgUserContact -UserId "john.doe@contoso.com" -ContactId "AAMkADkzZjk3ODk3LTgxMjQtNDI1NC1hYzBiLWZhM2Y4MTY1NzNlYwBGAAAAAABBbbQxofVsQqcQEAAAAAAA="

This command deletes a single Outlook contact from John Doe’s mailbox using the contact’s unique ID.


Bulk Removal of Contacts for a User

$contactsToRemove = @("ContactId1", "ContactId2", "ContactId3")
$userId = "john.doe@contoso.com"
foreach ($contactId in $contactsToRemove) {
    Remove-MgUserContact -UserId $userId -ContactId $contactId
}
                                           

This script loops through multiple Contact IDs and removes each contact from the specified user’s mailbox.

Remove-MgUserContact vs Remove-MgContact

Aspect Remove-MgUserContact Remove-MgContact
Scope User mailbox contacts Directory (organizational) contacts
Contact Type Personal Outlook contacts Tenant-wide external contacts
Requires UserId ✅ Yes ❌ No
Typical Usage Mailbox cleanup, migrations Managing organizational contacts
Affects Entra ID ❌ No ✅ Yes

In short:

  • Use Remove-MgUserContact for personal mailbox contacts
  • Use Remove-MgContact for tenant-level directory contacts

Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.

Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.

© Your Site Name. All Rights Reserved. Design by HTML Codex