사용자 만들기 스크립트의 일부로 회사를 기반으로 두 개의 AD 보안 그룹에 사용자를 추가하고 있습니다. 사용자가 그룹에 추가되고 있지만 경고 메시지가 나타납니다. 사용자가 올바르게 추가 될 때 경고 메시지가 표시되는 이유에 대해 혼란스러워합니다.그룹에 새 aduser를 추가 할 때 경고
경고 : ADGroup에 'CN = HS, CN = Users, DC = MY, DC = DOMAIN'을 (를) 추가 할 수 없습니다. 오류 : '지정된 계정 이름이 이미 그룹의 회원입니다'.
경고 : 'CN = HS Students, CN = Users, DC = My, DC = DOMAIN'을 (를) ADGroup에 추가 할 수 없습니다. 오류 : '지정된 계정 이름이 이미 그룹의 회원입니다'. 여기
내 생성 사용자 스크립트입니다
그래서foreach ($User in $ADUsers)
{
#Read user data from each field in each row and assign the data to a variable as below
$Username = $User.ID
$Password = $User.BDATE
$Firstname = $User.FNAME
$Lastname = $User.LNAME
$Department = $User.GRD
$Company = $User.SCHID #This field refers to the OU the user account is to be moved to
# Choose OU
Switch ($Company)
{
"1480" {$OU = 'OU=students,OU=users,ou=hs,dc=clasd,dc=net'}
"1479" {$OU = 'OU=students,OU=users,ou=elem,dc=clasd,dc=net'}
}
#Check to see if the user already exists in AD
if (Get-ADUser -F {SamAccountName -eq $Username})
{
#If user does exist, give a warning
Write-Warning "A user account with username $Username already exist in Active Directory."
}
else
{
#User does not exist then proceed to create the new user account
"Processing started (on " + $date + "): " | Out-File $log -append
"--------------------------------------------" | Out-File $log -append
#Account will be created in the OU provided by the $OU variable read from the CSV file
New-ADUser `
-SamAccountName $Username `
-UserPrincipalName "[email protected]" `
-Name "$Firstname $Lastname" `
-GivenName $Firstname `
-Department "$Department" `
-Company "$Company" `
-EmailAddress "[email protected]" `
-Surname $Lastname `
-Enabled $True `
-Scriptpath "login.vbs" `
-DisplayName "$Firstname $Lastname" `
-Path $OU `
-AccountPassword (convertto-securestring $Password -AsPlainText -Force) `
-ChangePasswordAtLogon $true
#Start-Sleep 5
# Add User to Groups
Get-Aduser -filter 'company -eq "1480"' | %{Add-ADPrincipalGroupMembership -Identity $_.SamAccountName -MemberOf "HS", "HS Students"}
}
}
회사가 1480 인 모든 사용자를 hs 및 hs 학생에 추가하고 해당 회사가 elem 및 elem 학생에게 1479 인 모든 사용자를 추가하려고합니다. –
WarningAction 매개 변수의 업데이트를 참조하십시오. –