我有下面的代碼可以讓用戶,但是當我在CSV文件中編寫組時,用戶不會添加到所述組中。 我能夠在服務器上運行這個權利。 該組是在一個更大的組中的一個子組。所以我也不確定如何通知Powershell我想要一組小組。我想添加一個用戶到一個基於名稱的CVS文件組
這是工作的路徑嗎? BILOMNI.BILPROMETRIC.ROOT/EasyServe_OU/EasyServeChannel_OU/Channel_CenterUsers_OU
我也有組唯一的名稱 RequestingAccess_CenterUsers_GG
$computer = $ENV:COMPUTERNAME;
$users = Import-Csv "C:\Users.csv";
Foreach ($user in $users)
{
#for ($i=0; $i -le 2000; $i++)
#{
# Grab required info
$userName = $user.User
$objOu = [ADSI]"WinNT://$computer"
$Group = $user.Group
# Create user
$objUser = $objOU.Create("User", $userName + $i)
$objUser.setpassword($user.password)
$objUser.SetInfo()
# Find target group and add the user to it
$de = [ADSI]"WinNT://$computer/$Group,Group"
$de.add([ADSI]"WinNT://$computer/$userName")
# }
}
The following exception occurred while retrieving member "add": "An invalid dn syntax has been specified.
"
At C:\Users\dennis.hayden\Desktop\makingbilusers.ps1:20 char:12
+ $de.add <<<< ([ADSI]"LDAP://$computer/$userName")
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : CatchFromBaseGetMember
下面是CSV文件,我使用:
User,Group,password
Masstestuser,RequestingAccess_CenterUsers_GG,[email protected]
你真的在'工作組'中工作,或者你在域中工作? – JPBlanc
我相信一個域名組有一個獨特的名字,所以我不確定爲什麼我不能使用它。 –
如果你在一個域上工作,你在Active-Directory上,所以最好用「LDAP://」代替「WinNT://」 – JPBlanc