Revoke-UserSession
SharePoint Online: Revokes a user's O365 sessions
#Requires -Version 5.1
#Requires -Modules Microsoft.Online.SharePoint.PowerShell
[CmdletBinding()]
Param(
[string]$User
)
Process {
try {
$cmdArgs = @{ ErrorAction = 'Stop'; User = $User; Confirm = $false }
$result = Revoke-SPOUserSession @cmdArgs | 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 }
}User name whose sessions to revoke