ps = '''
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$UserName = "%(domainuser)s"
$Password = "%(domainpassword)s"
$Domain = "%(domain)s"
$ct = [System.DirectoryServices.AccountManagement.ContextType]::Domain
$pc = New-Object System.DirectoryServices.AccountManagement.PrincipalContext $ct, $Domain
if (! $pc.ValidateCredentials($UserName, $Password)) {
	Throw "user/password not valid"
}
'''

name = 'domain-user-validate-password'
description = 'validate domain users password'
args = dict(
	domainuser=dict(help='the username', required=True),
	domainpassword=dict(help='the users expected password', required=True),
)


def pre(winrm):
	if not winrm.args.domain:
		winrm.parser.error('argument --domain is required')
