Bonjour tlm,

Je suis bloquer dans la création d'un script pour la création OU dans active directory

Voici ou je suis bloquer:



Voici mon script:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$objDomain = [ADSI]"LDAP://localhost:389/dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Groupes_Globaux")
$objOU.SetInfo()
 
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Direction")
$objOU.SetInfo()
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Secretaires")
$objOU.SetInfo()
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Comptables")
$objOU.SetInfo()
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Infographie")
$objOU.SetInfo()
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Informatique")
$objOU.SetInfo()
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Marketing")
$objOU.SetInfo()
$objDomain = [ADSI]"LDAP://ou=OU_Groupes_Globaux,dc=srvtest,dc=local"
$objOU = $objDomain.Create("organizationalUnit", "ou=OU_Ventes")
$objOU.SetInfo()
Et voici le résultat que j'aimerai obtenir

Créer une OU, dans cette OU créer une OU enfant et dans cette OU enfant créer deux OU enfant.

Voici en image le résultat souhaité




J'espère avoir été le plus clair possible

Si vous avez besoin de plus de renseignement demander les.

Merci d'avance