I recently ran into a need to test local user account passwords against a large set of servers. Naturally, any time I run into repeatable tasks like this, I turn to PowerShell to do the work for me. I googled to see if someone had already solved this problem (which is usually true 90% of the time) and found this really cool script over on Microsoft’s TechNet gallery. The script can be found here.
I liked how simple the script was, but I figured I could jazz it up by adding:
- Credential handling through PowerShell’s built in Get-Credential
- Change remote connectivity to use WSMan.
- Add array handling to feed lists of computers to check against.
I present Test-LocalCredential. To get started, simply call the function and provide a computer name as a parameter.
Test-LocalCredential -ComputerName Win2k16-file01.contoso.com
Then you will be presented with a credential provider popup. Simply enter the username and password you want to test.
For demonstration purposes I used the remote computer’s local administrator account credentials. After clicking OK, you should see output similar to the following:
CredentialCheck equaling True means that the credentials were successful. A return of False means the credentials are not correct.
You can also specify credentials separately in their own parameter like this:
$Cred = Get-Credential Test-LocalCredential -ComputerName Win2k16-File01 -Credential $Cred
As with all of the modules on this blog, you can find this tool on my github page for the ServerAdminCommon tool set.
Disclaimer: All scripts and other powershell references on this blog are offered “as is” with no warranty. While these scripts are tested and working in my environment, it is recommended that you test these scripts in a test environment before using in your production environment.