Posted On November 18, 2019

PowerShell: How to Properly Delete a Msol User Account

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: How to Properly Delete a Msol User Account
# Set the user ObjectID attribute variable
$msolUser="6f2fcfcd-...."

# Move user account to Recycle Bin
Remove-MsolUser -ObjectId $msolUser

# Purge from Recycle Bin
Get-MsolUser -ObjectID $msolUser -ReturnDeletedUsers | Remove-MsolUser -RemoveFromRecycleBin

# Remove from contacts bin
Get-MsolContact -ObjectID $msolUser | FL #Validate that this is a correct account
Get-MsolContact -ObjectID $msolUser | Remove-MsolContact

# Optional: if object is a group instead of a user
Get-MsolGroup -ObjectID $msolUser | Select EmailAdress,ProxyAddresses #Validate that this is the correct account
Get-MsolGroup -ObjectID $msolUser | Remove-MsolGroup

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

WordPress Custom CSS for Tables

WordPress themes can be customized, and one of the common practice is to add CSS…

PowerShell: How to Replace a System File – For Experimentation Purposes

# When attempting to rename a system protected file such as notepad.exe $notepadExe='C:\Windows\system32\notepad.exe' $newNotePadExe='C:\Users\rambo\Desktop\notepad.exe' rename-item…

PowerShell: Obtain List of Hyper-V Hosts in All Domains of All Forests

Version 0.03: https://blog.kimconnect.com/powershell-obtain-list-of-hyper-v-hosts-via-active-directory/ Version 0.02: https://blog.kimconnect.com/powershell-get-nic-mtus-of-all-hyper-v-hosts-in-domain-forest/ Previous version: # listHyperVHostsInForests.ps1# version 0.01# This function scans…