Skip to content

Instantly share code, notes, and snippets.

@LudovicOmarini
Created April 8, 2024 12:58
Show Gist options
  • Save LudovicOmarini/07a64ebb012d860b28b58bd7f077b5e3 to your computer and use it in GitHub Desktop.
Save LudovicOmarini/07a64ebb012d860b28b58bd7f077b5e3 to your computer and use it in GitHub Desktop.
Set immutableID for an Office 365 user to $null value
<#
.SYNOPSIS
Office 365 : Set immutableID to $null
.DESCRIPTION
This script set immutableID for an Office 365 user to $null value.
.EXAMPLE
.\Set_immutableid_to_null.ps1
#>
# Connexion à l'API Graph
Connect-MgGraph
# Define the office 365 user
$user = Read-Host "Enter email adress "
# Command to set $null value
Invoke-MgGraphRequest -Method PATCH -Uri "https://graph.microsoft.com/v1.0/Users/$($mail)" -Body @{OnPremisesImmutableId = $null}
# Déconnexion de la session de l'API Graph
Disconnect-MgGraph
# Supprimer les variables de la session Powershell
Remove-Variable * -ErrorAction SilentlyContinue
Remove-Module * -ErrorAction SilentlyContinue
$error.Clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment