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

PowerShell: Script to Stop, Start, Disable, and Enable Exchange Server

<#This script contains a set of functions to administer Exchange 2010, 2013, 2016, and 3000.…

The Process of Adding a New Hyper-V Server Into a Cluster and the Associated Virtual Machine Manager (VMM)

These are the steps: Install WindowsWindows 2019 Data Center Edition is the standard as of…

PowerShell: Check a List of Windows Computers for Online & Offline Statuses

# checkOnlineComputers.ps1 # Set a list of computers in a text file $computerListFile='C:\Temp\computerlist.txt' # Read…