Skip to content

Instantly share code, notes, and snippets.

@JohnLBevan
Last active February 8, 2024 18:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnLBevan/ce79b234881ebe732c20ac54d2ca72ae to your computer and use it in GitHub Desktop.
Save JohnLBevan/ce79b234881ebe732c20ac54d2ca72ae to your computer and use it in GitHub Desktop.
If you want to check the credentials you have for a local user account are correct, you can use this script (from: https://blog.idera.com/database-tools/test-local-user-account-credentials )
$username = 'username'
$password = 'password'
$computer = $env:COMPUTERNAME
Add-Type -AssemblyName 'System.DirectoryServices.AccountManagement'
$obj = [System.DirectoryServices.AccountManagement.PrincipalContext]::new('machine',$computer)
$obj.ValidateCredentials("$computer\$username", $password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment