Skip to content

Revoke-TenantServicePrincipalPermission

SharePoint Online: Revokes a service principal permission

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

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$ObjectId
)

Process {
    try {
        $result = Revoke-SPOTenantServicePrincipalPermission -ObjectID $ObjectId -Confirm:$false -ErrorAction Stop | Select-Object *
        if ($null -ne $result) { foreach ($item in $result) { $item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force } }
    }
    catch { throw }
}

Object ID of the permission grant to revoke

An interactive directory of PowerShell scripts.