Blocking a user in Microsoft 365 (Office 365) from signing in can be an effective way to restrict access without directly modifying user passwords or deleting accounts. This can be done easily using Microsoft Graph API via PowerShell.
Run Install-Module -Name Microsoft.Graph -Scope CurrentUser
command to install Microsoft Graph PowerShell module.
You must authenticate to Microsoft Graph with the required permission User.ReadWrite.All.
Connect-MgGraph -Scopes "User.ReadWrite.All"
is the command.
Find the user you want to block. You can identify them by their user principal name (UPN), email, or object ID.
To block the user, you’ll need to disable their sign-in status. This can be done by setting the accountEnabled parameter to $false. This doesn't delete the user or their data but prevents them from signing in.
To unblock the user, you’ll need to enable their sign-in status. This can be done by setting the accountEnabled parameter to $true
Note: Read Microsoft Documentation on Blocking Microsoft 365 user accounts using Graph PowerShell for more information.
© m365corner.com. All Rights Reserved. Design by HTML Codex