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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| scriptVersion = "1.0"
Set objShell = CreateObject("WScript.shell")
Set objEnv = objShell.Environment("Process")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
strUserName = objEnv("USERNAME")
strComputerName = lcase(objEnv("COMPUTERNAME"))
bPath = "\\127.0.0.1\listing" ' Server and path to save files
bFile = bPath & "\" & strComputerName &"-" & strUserName & "-NetDrives.txt"
'Setup output file
If objFSO.FileExists(bFile) then
Set objTextFile = objFSO.OpenTextFile(bFile, 8, True) ' 8 = appending
Else
Set objTextFile = objFSO.OpenTextFile(bFile, 2, True) ' 2 = writing
End if
objTextFile.WriteLine Now & " ::: Drive mappings listing v" & scriptVersion
'Loop through current network drives
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
objTextFile.WriteLine colDrives.Item(i) & vbTab & colDrives.Item (i + 1)
'Cette partie de code à modifier pour les droits-----------------------------
arrComputers = Array(".")
For Each strComputer In arrComputers
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colACLs = objWMI.ExecQuery("Select * from win32_share")
For Each share In colACLs
strDir = share.path
strWrite = "SHARE NAME] " & ucase(Share.name)
strDir = Replace(strDir,"\","\\")
Set colACLs = objWMI.ExecQuery("Select * from win32_logicalFileSecuritySetting WHERE Path='" & strDir & "'",,48)
for each objItem in colACLs
If objItem.GetSecurityDescriptor(objSD) Then
DisplayFileSecurity = False
End If
For each objAccessList in objSD.DACL
strAccessList = objAccessList.Trustee.Domain & "\" & objAccessList.Trustee.Name
if left(strAccessList,1) = "\" then
strAccessList = right(strAccessList,len(strAccessList) -1)
end if
prevWrite = strWrite
strWrite = "GROUP] " & Ucase(strAccessList)
if prevWrite <> strWrite and strWrite <> "GROUP] " then
objTextFile.WriteLine ucase(strWrite)
objTextFile.WriteLine strNewText
end if
Next
Next
Next
Next
'fin---------------------------------------------------------------
Next
Set objShell = Nothing
Set objFSO = Nothing
Set objNetwork = Nothing
Wscript.Quit(ExitErrorLevel) |
Partager