Skip to content

Instantly share code, notes, and snippets.

@mdowst
Last active November 11, 2017 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdowst/08ed7f2c1bf063aa6d28a01feefa8fc0 to your computer and use it in GitHub Desktop.
Save mdowst/08ed7f2c1bf063aa6d28a01feefa8fc0 to your computer and use it in GitHub Desktop.
# Use to Test AD Credentials
function Test-ADCredential {
[CmdletBinding()]
Param
(
[string]$UserName,
[string]$Password
)
if (!($UserName) -or !($Password)) {
Write-Warning 'Test-ADCredential: Please specify both user name and password'
} else {
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
$DS.ValidateCredentials($UserName, $Password)
}
}
Test-ADCredential 'user' 'Password'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment