Create script to generate domain users in Powershell

0

I have to create a script that makes me a GPO for the Student Group and another for the teaching group, and create a pair of users per group, however it does not run. The code developed is the following:

 #Creamos las GPO

New-ADOrganizationalUnit Profesorado
New-ADOrganizationalUnit Alumnado
#Creamos los grupos de usuarios

New-ADGroup -Name "Profesorado" -SamAccountName Profesorado -GroupCategory Security -GroupScope Global -DisplayName "Profesorado" -Path " OU=Profesorado,DC=ras2017,DC=org " -Description "Grupo del profesorado"
New-ADGroup -Name "Alumnado" -SamAccountName Alumnado -GroupCategory Security -GroupScope Global -DisplayName "Redaccion Solvetic" -Path " OU=Redaccion,DC=solvetic,DC=com " -Description "Alumnado"

#Creamos los usuarios y los asiganmos en el grupo correspondiente

New-ADUser -Name Rafa -GivenName Rafa -Surname Aybar -Path "CN=Alumnado,DC=rafael,DC=org" -accountPassword (ConvertTo-SecureString -AsPlainText "Rafa-1994" -Force)
New-ADUser -Name Al1 -GivenName Al1 -Surname 2 -Path "CN=Alumnado,DC=rafael,DC=org" -accountPassword (ConvertTo-SecureString -AsPlainText "Rafa-1994" -Force)
New-ADUser -Name Al2-GivenName Al2-Surname 2 -Path "CN=Alumnado,DC=rafael,DC=org" -accountPassword (ConvertTo-SecureString -AsPlainText "Rafa-1994" -Force)
New-ADUser -Name Prof1 -GivenName 1 -Surname 1 -Path "CN=Profesorado,DC=rafael,DC=org" -accountPassword (ConvertTo-SecureString -AsPlainText "Rafa-1994" -Force)
New-ADUser -Name Prof2 -GivenName 2 -Surname 2 -Path "CN=Profesorado,DC=rafael,DC=org" -accountPassword (ConvertTo-SecureString -AsPlainText "Rafa-1994" -Force)
Add-ADGroupMember "Alumnado" Rafa,Al1,Al2
Add-ADGroupMember "Profesorado" Prof1,Prof2
    
asked by ras212 06.03.2017 в 22:01
source

1 answer

1

Your problem is on the route, you do not have the DN of an OU .

Try changing this:

  

-Path "CN = Students, DC = rafael, DC = org

Because of this:

  

-Path "OU = Students, DC = rafael, DC = org

Note that yours begins with CN , it must be OU .

    
answered by 28.03.2017 / 18:42
source