The Remove-MsolUser cmdlet in PowerShell removes a user from Microsoft Office 365. This command deletes the user, their licenses, and any other associated data.
The syntax to delete a user from Azure Active Directory is given below.
Remove-MsolUser -ObjectId <Guid> -UserPrincipalName <String> [-RemoveFromRecycleBin] [-Force] [-TenantId <Guid>] [<CommonParameters>]
In this article, we will discuss how to use the Remove-MsolUser cmdlet in PowerShell to remove a user, delete a user without confirmation, and remove a user from the Recycle Bin.
How to Remove a User From Office 365
To remove a user from Office 365 with PowerShell, use the Remove-MsolUser cmdlet.
Remove-MsolUser -UserPrincipalName "[email protected]"
The Remove-MsolUser command uses the
-UserPrincipalName parameter to specify the user’s principal name. This command removes the user with the principal name “[email protected]” from the Azure Active Directory.
If the user has any licenses assigned to him, the cmdlet removes these licenses. The command prompts you to confirm the remove operation.
How to Remove a User from Office 365 without Confirmation
To remove a user from Office 365 without confirmation, use the
Remove-MsolUser cmdlet with the
-Force parameter. The
-Force parameter indicates that the command does not prompt you for confirmation.
Remove-MsolUser -UserPrincipalName "[email protected]" -Force
This command removes the “[email protected]” user from the Azure Active directory. If the user has any licenses, the command removes these.
How to Delete a User from the Recycle Bin
To delete a user from the Recycle Bin in Azure Active Directory, use the Remove-MsolUser cmdlet with the
-RemoveFromRecycleBin parameter. The
-RemoveFromRecycleBin parameter permanently removes a deleted user from the recycle bin.
Remove-MsolUser -UserPrincipalName "[email protected]" -RemoveFromRecycleBin
This command removes a user “[email protected]” from the Azure Active Directory Recycle Bin. The command permanently removes a user.
I hope the above article on how to use the Remove-MsolUser cmdlet in PowerShell to remove a user from Office 365, remove a user permanently is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.