Script repository

Check whether Microsoft 365 user account is blocked

Updated on: Jan 18, 2026, Views: 3120

Microsoft 365

The script checks whether a user is blocked from signing in to Microsoft 365. To execute the script use the If PowerShell script returns true condition in a business rule, custom command or scheduled task configured for the User object type. The script returns $true if sign in is blocked.

$Context.ConditionIsMet = $False

try
{
    $signInBlocked = $Context.TargetObject.Get("adm-O365AccountBlocked")
}
catch
{
    return
}

$Context.ConditionIsMet = !($signInBlocked)

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.