Last active
November 11, 2017 16:25
-
-
Save mdowst/08ed7f2c1bf063aa6d28a01feefa8fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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