0

我得到了这个脚本:

$Users = Import-Csv C:\Users\Administrator\Desktop\userImport\userTest.csv
$Users | % { 

# Setting data
$computer = [ADSI]"WinNT://."
$userGroup = [ADSI]"WinNT://./Users,Group"

# Create user itself
$createUser = $computer.Create("User",$_.userid)

# Set password (print1!)
$createUser.SetPassword($_.password)
$createUser.SetInfo()

# Create extra data
$createUser.Description = "Import via powershell"
$createUser.FullName = $_.'full name'
$createUser.SetInfo()

# Set standard flags (Password expire / Password change / Account disabled)
$createUser.UserFlags = 64 + 65536 # ADS_UF_PASSWD_CANT_CHANGE + ADS_UF_DONT_EXPIRE_PASSWD
$createUser.SetInfo()

# Adduser to standard user group ("SERVER02\Users")
$userGroup.Add($createUser.Path)
}

但我收到错误消息:无法将成员添加到本地组或从本地组中删除,因为该成员不存在。我怎样才能解决它?

4

1 回答 1

1

尝试在此处更改.计算机名称:

$computer = [ADSI]"WinNT://."

作为

$compname = hostname
$computer = [ADSI]"WinNT://$compname"
于 2012-11-27T16:46:51.630 回答