Skip to main content

Security helpers

Requires a Microsoft Graph session. For full and always-up-to-date details, use Get-Help <FunctionName> -Detailed (or -Examples).

Disable-UserDevices

Disable all registered devices for specified users.

Syntax

Disable-UserDevices -UserPrincipalName <String[]> [-PassThru]
ParameterDescriptionRequired
UserPrincipalName (Identity)Users whose registered devices will be disabled. Pipeline accepted.Yes
PassThruEmit the impacted devices.No

Example

Disable-UserDevices -UserPrincipalName user1@contoso.com,user2@contoso.com -WhatIf

Disable-UserSignIn

Block sign-in (AccountEnabled = $false) for specified users.

Syntax

Disable-UserSignIn -UserPrincipalName <String[]> [-PassThru]
ParameterDescriptionRequired
UserPrincipalName (Identity)Users to block. Pipeline accepted.Yes
PassThruEmit the impacted users.No

Example

Disable-UserSignIn -UserPrincipalName user1@contoso.com -Confirm:$false

Revoke-UserSessions

Force sign-out by revoking refresh tokens for users.

Syntax

Revoke-UserSessions [-All] [-UserPrincipalName <String[]>] [-Exclude <String[]>] [-PassThru]
ParameterDescriptionRequired
AllTarget every user in the tenant.No
UserPrincipalName (Identity)Users to target. Pipeline accepted.No
ExcludeUsers to skip (applies to both -All and explicit lists).No
PassThruEmit the impacted users.No

Examples

Revoke-UserSessions -UserPrincipalName user1@contoso.com,user2@contoso.com
Revoke-UserSessions -All -Exclude breakglass@contoso.com -Confirm:$false

Notes:

  • Supports -WhatIf/-Confirm for safety.
  • Skips missing users and reports exclusions.