How to validate windows domain credentials via the command line?
10,070
There's a very handy PowerShell function here for testing credentials:
Function Test-ADCredentials {
Param($username, $password, $domain)
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext($ct, $domain)
New-Object PSObject -Property @{
UserName = $username;
IsValid = $pc.ValidateCredentials($username, $password).ToString()
}
}
Example use: Test-ADCrendentials -Username joel -Password splotchy -Domain stackoverflow.com
Related videos on Youtube
Author by
jimmy_terra
Updated on September 18, 2022Comments
-
jimmy_terra over 1 year
I want to validate a set of credentials against the domain controller. e.g.:
Username: STACKOVERFLOW\joel Password: splotchy
Can I do this via the command line?
-
Scott Chamberlain almost 11 yearsIs the computer you are doing the testing on already a member of the domain?
-