yeap ... otherwise it could'nt create the account in first place.
The problem is in the secound part when it tries to add the created account to local admin gruop.
Code:
$Computer = "192.168.0.10"
$NewUser = "David"
$NewPassword = "passwd"
$Group = "Administrators"
$FullName = "David J"
$Domain = "Home"
CreateLocalUserAccount ($Computer,$Domain,$NewPassword,$NewUser,$FullName,$Group)
Function CreateLocalUserAccount ($Computer,$Domain,$NewPassword,$NewUser,$FullName,$Group)
$Accounts = GetObject("WinNT://" + $Domain + "/" + $Computer + ",Computer")
$User = $Accounts.Create("user", $NewUser)
$SetUserPassword = $User.ChangePassword("", $NewPassword)
$User.SetPassword ($NewPassword)
$User.Put ("FullName", $FullName)
$User.SetInfo
AddUserToLocalGroup ($Computer,$NewUser,$Group)
EndFunction
Function AddUserToLocalGroup ($Computer,$NewUser,$Group)
$objGroup = GetObject("WinNT://" + $Computer + "/" + $Group + ",group")
$objUser = GetObject("WinNT://" + $Computer + "/" + $NewUser + ",user")
$objGroup.Add($objUser.ADsPath)
EndFunction