I can successfully use Powershell to tell if a user authenticates in Active Directory:

Function Test-ADAuthentication {
    (new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null

Test-ADAuthentication "test" "Password1"

However, I cannot for the life of me figure out how to:

  1. Check if the password needs to be reset, while
  2. Verifying the credentials sent did work on their last password.

How could one go about this?


1 Answer 1


Credentials can be tested by running a process. An example below,

Start-Process -FilePath cmd.exe /c -Credential (Get-Credential -UserName $username -Message 'Test Credential')

Or simply:

Start-Process -FilePath cmd.exe /c -Credential (Get-Credential)

You will be presented with a prompt to enter a password. If you need read the password from a string (bad practice), you need to initialize the credential object beforehand. More details on that method can be found in the help.

Get-Help Get-Credential

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.