Bonjour avec vous un ptit script pour ajouter un ordinateur à un groupe active directory ?


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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
strOU = "CN=MAC_Advitium_Package_Computers, OU=software, OU=groups, OU=metso minerals, OU=mac," 
 
Const PathMDB   = "\\macs16\poste_advitium_test" 
 
 
' Lien avec l'AD
 
Set objRootLDAP = GetObject("LDAP://rootDSE")
 
Set objGroup = GetObject("LDAP://"& strOU & objRootLDAP.Get("defaultNamingContext")) 
 
 
' Creation du tableau qui liste les ordinateurs
 
Set fso = CreateObject("Scripting.FileSystemObject")
imax = 0
'début de l'énumération
For Each fichier In fso.GetFolder(PathMDB).Files
    Set fileItem = fso.GetFile(fichier)
 
    imax = imax + 1
    ReDim Preserve Tableau(1, imax)
    Tableau(1, imax) = Fichier.Name
 
 
    Set fileItem = Nothing
Next
 
 
' Boucle sur le tableau
 
For i = 1 To imax
 
 
' Ajout computers a partir du tableau
objGroup.Add Tableau(1,i).AdsPath
 
 
 Next
 
WScript.Quit