vaguerent/plugins/hosts/windows/scripts/check_credentials.ps1
2018-01-12 15:46:31 -08:00

19 lines
483 B
PowerShell

Param(
[Parameter(Mandatory=$true)]
[string]$username,
[Parameter(Mandatory=$true)]
[string]$password
)
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext(
[System.DirectoryServices.AccountManagement.ContextType]::Machine,
$env:COMPUTERNAME
)
if ( $DSContext.ValidateCredentials( $username, $password ) ) {
exit 0
} else {
exit 1
}