Get-Credential and Validate

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Posts: 57
Joined: Mon Apr 25, 2016 1:08 am
Location: United Kingdom

Get-Credential and Validate

Post by dank42 » Mon Nov 19, 2018 5:10 am


I have a GUI which requires the user to enter their AD Credentials for certain tasks to run.

I want to be able to validate the users credentials and return an error if the password is incorrect. What is the best method for this?

I am using Get-Credential

Code: Select all

$Cred = Get-Credential -UserName $env:USERNAME.ToLower() -Message "Authentication"

User avatar
Posts: 13682
Joined: Tue May 22, 2007 9:57 am

Re: Get-Credential and Validate

Post by jvierra » Mon Nov 19, 2018 6:44 am

The only way to validate credentials is to try and use them.