Skip to content

Remove-GeoAdministrator

SharePoint Online: Removes a geo administrator

#Requires -Version 5.1
#Requires -Modules Microsoft.Online.SharePoint.PowerShell

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true, ParameterSetName = "User")]
    [string]$UserPrincipalName,
    [Parameter(Mandatory = $true, ParameterSetName = "Group")]
    [string]$GroupAlias
)

Process {
    try {
        if ($PSCmdlet.ParameterSetName -eq "User") { Remove-SPOGeoAdministrator -UserPrincipalName $UserPrincipalName -ErrorAction Stop }
        else { Remove-SPOGeoAdministrator -GroupAlias $GroupAlias -ErrorAction Stop }
        [PSCustomObject]@{ Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"; Status = "Success"; Message = "Geo administrator removed" }
    }
    catch { throw }
}

UPN of the user to remove

Alias of the group to remove

An interactive directory of PowerShell scripts.