This small PowerShell script checks whether a user account can authenticate against Active Directory. It is useful for quickly validating credentials during troubleshooting, onboarding, or when you want to confirm that a specific account and password combination works as expected.
What the script does
The script prompts for a user name and password, then uses the .NET PrincipalContext class to validate those credentials against Active Directory. If the login is successful, the script shows a success message; if not, it reports that authentication failed.
How it works
First, the script loads the required .NET assembly for Active Directory account management. Then it either uses the supplied credentials or asks for them interactively. After that, it creates an AD context and runs a credential check against the selected domain or domain controller.
Why this is useful
This is a simple but practical way to test whether a user can log on without having to open additional tools. It can help isolate issues such as wrong passwords, account problems, or domain connectivity errors.
GitHub download
Download the script here: GitHub repository