ps = '''
$d = new-object DirectoryServices.DirectoryEntry("LDAP://%(domain)s","%(user)s@%(domain)s","%(password)s")
$searcher = New-Object System.DirectoryServices.DirectorySearcher($d)
$searcher.PageSize = 1000
$searcher.filter = "(sAMAccountName=%(domainuser)s)"
$Result = $searcher.FindOne()
If ($Result -ne $Null) {
	$user = $Result.GetDirectoryEntry()
	$user.SetPassword("%(userpassword)s")
	exit 0
}
exit 1
'''
name = 'change-user-password'
description = 'change user password'
args = dict(
	domainuser=dict(help='change password for this user', required=True),
	userpassword=dict(help='the password string', required=True),
)


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