Managing user sessions in Microsoft 365 is crucial for ensuring security and control over your organization's data. The Revoke-MgUserSignInSession
cmdlet allows administrators to revoke active user sign-in sessions in Microsoft 365, forcing reauthentication. This guide explores the syntax, examples, tips, use cases, possible errors, and solutions to help you effectively use this cmdlet.
Revoke-MgUserSignInSession -UserId <String>
Parameters:
You'll be prompted to enter or pass the UserId or UPN if you use the cmdlet directly. The user session is revoked when you pass the UserID or UPN.
Revoke-MgUserSignInSession
This example shows how to revoke a user’s session by directly passing their ID or UPN to the cmdlet.
# Revoke sessions for a specific user
Revoke-MgUserSignInSession -UserId "user@example.com"
Read-Host -AsSecureString
to avoid displaying input in plaintext.Get-MgUserSignInActivity
to identify users with suspicious login activity before revoking sessions.User.ReadWrite.All
permission, to execute this cmdlet.No, it only invalidates the user's refresh tokens. Existing access tokens remain valid until they expire, so the user may not be signed out immediately.
The cmdlet does not return output. To verify, check Azure AD audit logs or track changes in sign-in behavior using Get-MgAuditLogSignIn.
No, Revoke-MgUserSignInSession is intended for user accounts only, not for applications or service principals.
No. Revoking sign-in sessions only invalidates refresh tokens and forces reauthentication. The user’s existing password remains valid unless explicitly reset using Update-MgUser
or other password reset methods.
Yes, in some cases. If applications cache data locally (for example, Outlook OST files or Teams offline files), users may still see previously synced content. Revoking sessions only blocks future authentication and access to cloud resources.
Error | Cause | Solution |
Insufficient privileges to complete the operation | The admin account lacks the required permissions | Assign the User.ReadWrite.All permission to your account or role. |
Invalid user ID or UPN provided | The -UserId parameter value is incorrect or does not exist in your tenant. |
Verify the user ID or UPN using the Get-MgUser cmdlet:
|
Resource not found | The user specified by the -UserId does not exist |
Double-check the ID or UPN for typos and ensure the user exists in the tenant. |
Revoking Tokens Doesn’t Immediately Log Out the User
Revoke-MgUserSignInSession
, users may still retain access for a short time until the current tokens expire. This cmdlet invalidates refresh tokens, but existing access tokens remain valid until their expiry.
No Output Is Expected After Successful Execution
Revoke-MgUserSignInSession
cmdlet does not return any output upon success. To confirm revocation, check audit logs or monitor recent user sign-ins using Get-MgAuditLogSignIn
.
Revoke-MgUserSignInSession
terminates all active refresh tokens for the user — across browsers, mobile apps, and desktop clients.
This ensures sign-ins are invalidated everywhere, forcing the user to reauthenticate before accessing Microsoft 365 resources again.
The Revoke-MgUserSignInSession
cmdlet is a powerful tool for managing Microsoft 365 user sessions. Whether you’re responding to a security incident or enforcing new policies, this cmdlet provides administrators with a straightforward way to revoke access and enhance security. By understanding its syntax, usage, and potential pitfalls, you can effectively utilize this cmdlet to protect your organization’s resources.
© m365corner.com. All Rights Reserved. Design by HTML Codex