# -*- coding: utf-8 -*-

name = 'new-user-in-ou'
description = 'Create a user object in AD'
args = {
	'user-name': dict(help='Name of the user'),
	'user-password': dict(help='Password of the user', default='Univention.99'),
	'group': dict(help='Add user to this group'),
        'path' : dict(help="ldap ou path where new user will be created"),
}

ps = '''
$ErrorActionPreference = "Stop"
$description = "winrm test user"
$password =  "%(user_password)s"| ConvertTo-SecureString -asPlainText -Force
$group = "%(group)s"
New-ADUser -Name "%(user_name)s" -ChangePasswordAtLogon 0 -Description "$description" -AccountPassword($password) -PassThru -Path "%(path)s" | Enable-ADAccount
Get-ADUser "%(user_name)s" -Properties Enabled | Format-Table  Name, Enabled
if ($group -ne "None") {
	Add-ADGroupMember "%(group)s" –Member "%(user_name)s"
}
'''
