MicrosoftMicrosoft Office 365Powershell

How to Unlock a User Account in Office 365 Using PowerShell

User accounts in Office 365 (Microsoft 365) can become locked for various reasons, such as repeated incorrect password attempts. When this happens, administrators need a way to quickly and efficiently unlock those accounts. Using PowerShell is one of the most effective methods.

Prerequisites

  • Powershell with Active Directory Module: Ensure you have PowerShell installed and the Active Directory module imported (use Add-WindowsFeature RSAT-AD-Powershell).
  • Office 365 Administrator Permissions: You must have the necessary administrator credentials to connect to Azure Active Directory and manage user accounts.

Steps to Unlock a User Account in Office 365 Using PowerShell

1: Connect to Azure Active Directory:

Connect-MsolService

Enter your Office 365 administrator credentials when prompted.

2: Identify the Locked User Account:

Get-ADUser -Identity 'username' -Properties LockedOut | Select-Object Name,Lockedout

3: Unlock the Account:

Unlock-ADAccount -Identity 'username'

Again, replace ‘username’ with the relevant account name.

Bulk Unlocking Locked Accounts

For unlocking multiple locked out accounts, use these commands:

Search-ADAccount -Lockedout | Select-Object Name, SamAccountName
Search-ADAccount -LockedOut | Unlock-AdAccount

Conclusion

By mastering these PowerShell commands for Office 365, you’ll streamline your administrative tasks when dealing with locked user accounts. Remember, consistent SEO practices will help your article get noticed by users who need this information.

Muhammad Faizan

Hi, My name is Muhammad Faizan and i have spent last 15 years working as System Administrator mainly with Microsoft Technologies. I am MCSE, MCTP, MCITP, certified professional. I love scripting and Powershell is the scripting language i am in love with.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button