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 42 43
| Dim fso, flog
Dim WshShellObj,WshProcessEnv
Dim fileLogPath,ComputerName
Dim objGroup,strComputer,objUser,objADSysInfo
'récupère le nom de connexion réseau et le nom de l'ordinateur
Set WshShellObj = CreateObject("WScript.Shell")
Set WshProcessEnv = WshShellObj.Environment("Process")
ComputerName = WshProcessEnv ("COMPUTERNAME")
'Construit le nom du fichier log à partir de la variable d'environnement
' %COMPUTERNAME%.CSV
fileLogPath = LOGSHARE & ComputerName & ".csv"
'Création du fichier log
Set fso = CreateObject("Scripting.FileSystemObject")
Call OpenFile(fileLogPath,flog,ForWriting)
'Ecriture du fichier log
strComputer = "."
Set objGroup = GetObject("WinNT://" & strComputer & "/Administrateurs,group")
'récupere l'OU
Set objADSysInfo = CreateObject("ADSystemInfo" )
For Each objUser in objGroup.Members
flog.Writeline Date & ";" & ComputerName & ";" & objUser.Name & ";" & objUser.Class & ";" & objADSysInfo.SiteName
Next
'-------------------------------------------------------------------------
' Open file (r/w) and return associated handle
'-------------------------------------------------------------------------
Function OpenFile(byval vFileName,ByRef vHandle,byval vMode)
Set vHandle = fso.OpenTextFile(vFileName, vMode, True)
If err.number<> 0 Then
wscript.echo "Error while opening "+vFileName+ " --- error n°"+CStr(Err.Number) + "[" + Err.Description+"]"
Wscript.quit (Err.Number)
End If
End Function |
Partager