|
|
|
|||||||
|
ICT-Hotlist TopicFind locked out Windows Domain Users with PowerShellHave some colleagues that use BYOD with their own (e-mail) synchronised programs? Changing their Windows passwords on their desktop, notebook or even through a Citrix portal results in log on problems? Then one of their devices might be using an old password to synchronise, resulting in an Active Directory user account lockout.This PowerShell script determines if someone is locked out from the Active Directory Domain Services (AD DS), and when the situation occurred. It reports :
No-one locked out
or a list formatted as:
Name Since Locked Out
Using this script on a Windows 7, 8 or 10 desktop? You may need to load the Active Directory module by
configuring RSAT.
Read more about RSAT here
Johan 2015-11-16 22:29:37 True
# This PowerShell script determines if someone is locked out from the
Want to test this script? Just run the command line interface (cli) command:
# Active Directory, and when the situation occurred: # It reports # No-one locked out # or a list of: # Name Since Locked Out # Johan 2015-11-16 22:29:37 True # (C)Copyrights 2015 - 2024 vanSoest.it by J. van Soest. # Load the Active Directory PowerShell module. Import-Module ActiveDirectory # Clear the screen so the data is nicely presented. cls Write-Host "This PowerShell script determines if someone is locked out from the " Write-Host "Active Directory, and when the situation occurred:" # Define an object and load it with all the users currently locked out $LOUsers = Search-ADAccount -lockedout # Check if the object contains any members if ( $LOUsers -ne $null ) { # Object contains members so write the table headers on the screen (tab seperated) Write-Host "Name`tSince`tLocked Out" # Now loop through all the members and write data to screen tab formatted. foreach ($LOUser in $LOUsers){ $Usr = Get-ADUser $LOUser -Properties * $Time = $Usr.lockoutTime # Format the Active Directory date number using the filesystem datetime object $strTime = [datetime]::FromFileTime($Time).ToString("yyy-MM-dd HH:mm:ss") Write-Host $Usr.Name,"`t",$strTime,"`t",$Usr.lockedout } } else{ # The object is empty. So no one is locked out. Write-Host "No-one locked out" }
runas /user:%userdomain%\<testuser> cmd.exe
Run it 5 times (substitute the retries lock out value of your domain), with a test user account and fill in a wrong password
each time. The PowerShell script will show a locking of the <testuser> account.
Account Lockout Status (LockoutStatus.exe)Microsoft also has a tool called LockoutStatus that does not require PowerShell and has a GUI. Read more here
You may vote your opinion about this article:
Scripts and programming examples disclaimerUnless stated otherwise, the script sources and programming examples provided are copyrighted freeware. You may modify them, as long as a reference to the original code and hyperlink to the source page is included in the modified code and documentation. However, it is not allowed to publish (copies of) scripts and programming examples on your own site, blog, vlog, or distribute them on paper or any other medium, without prior written consent.Many of the techniques used in these scripts, including but not limited to modifying the registry or system files and settings, impose a risk of rendering the Operating System inoperable and loss of data. Make sure you have verified full backups and the associated restore software available before running any script or programming example. Use these scripts and programming examples entirely at your own risk. All liability claims against the author in relation to material or non-material losses caused by the use, misuse or non-use of the information provided, or the use of incorrect or incomplete information, are excluded. All content is subject to change and provided without obligation. |