Test AD account credentials with PowerShell

In this article I’ll show you a function from Techibee which will provide a easy way to verify if the given credentials are valid or not. In this function I use classes and methods in System.DirectoryServices.AccountManagement name space, with focus on the ValidateCredentials method.

The Test-ADCredential function takes the PSCredential argument as input. This is the optional one. If you don’t specify it, it will prompt you to enter the credentials. That means we can use this function in your PowerShell scripts as well as for testing needs.

PowerShell function


You can run the Test-ADCredentials with or without arguments. When you run it without credentials it will ask you enter the credentials.


If you run this function by passing credential object as argument then it will return the output.

News Source: Techibee

About Lex van der Horst 201 Articles

Be the first to comment

Leave a Reply