Here is a snippet that verifies a local user account. Simply submit a username and a password. You get back either $true or $false:
$username = 'Administrator'
$password = '[email protected]'
$computer = $env:COMPUTERNAME
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$obj = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('machine',$computer)
ReTweet this Tip!
Is there any ways to detect a list of servers with different password?
This is extremely valuable. In our environment we have standardized our local admin name and password using group policy preferences. When installing software enterprise wide with SCCM some packages require that they be invoked as the user who is not a local admin but install the package as a local admin. By having a secure but standardized user name and password as the local admin we can use that. But unfortunately some workstations are not properly standardized by the gpp and thus the local admin user name and password may not be correct resulting in a failed software installation. By using this code I can check that the local admin name AND password are correct and react accordingly. Well Done! practical real world code!
Powered by IDERA