Skip to content

Revoke-MgmtGraphUserSignInSession

MgmtGraph: Revokes all active sign-in sessions for a Microsoft Graph user

#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Users.Actions

[CmdletBinding()]
Param (
    [Parameter(Mandatory = $true, Position = 0)]
    [string]$Identity
)

Process {
    try {
        $status = Revoke-MgUserSignInSession -UserId $Identity -ErrorAction Stop
        
        $result = [PSCustomObject]@{
            UserIdentity = $Identity
            Action       = "SignInSessionsRevoked"
            Status       = $status
            Timestamp    = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        }

        Write-Output $result
    }
    catch {
        throw
    }
}

Specifies the UserPrincipalName or ID of the user to revoke sessions for.

An interactive directory of PowerShell scripts.