Created
April 8, 2024 12:58
-
-
Save LudovicOmarini/07a64ebb012d860b28b58bd7f077b5e3 to your computer and use it in GitHub Desktop.
Set immutableID for an Office 365 user to $null value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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