Commands › SharePoint Online

Remove-SPOUser

SharePoint Online Microsoft.Online.SharePoint.PowerShell Remove-*

Removes a user or a security group from a site collection or a group.

Quick start script

# Remove-SPOUser — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-SPOService -Url https://$org-admin.sharepoint.com

# 2. Capture the current state first — you cannot roll back what you never recorded
$before = Get-SPOUser
$before | Format-List

# 3. Make the change
Remove-SPOUser -LoginName <String> -Site <SpoSitePipeBind>

# 4. Verify and diff
$after = Get-SPOUser
Compare-Object ($before | Out-String) ($after | Out-String)

Syntax

Remove-SPOUser -Site <SpoSitePipeBind> -LoginName <String> [-Group <String>] [<CommonParameters>]

Parameters (3)

ParameterTypeRequiredWhat it controls
-Group String Specifies the group to remove the user from. If not specified, the cmdlet removes the user from all groups.
-LoginName String yes Specifies the user name.
-Site SpoSitePipeBind yes Specifies the site collection to remove the user from.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.