Bunenas tardes amigos:
me darian una mano para hacer que este script sea recursivo y que busque en todas las carpetas.
un abrazo y como siempre mil gracias!!!
Option Explicit
Const SE_DACL_PRESENT = &h4
Const ACCESS_ALLOWED_ACE_TYPE = &h0
Const ACCESS_DENIED_ACE_TYPE = &h1
Const FILE_ALL_ACCESS = &h1f01ff
Const FOLDER_ADD_SUBDIRECTORY = &h000004
Const FILE_DELETE = &h010000
Const FILE_DELETE_CHILD = &h000040
Const FOLDER_TRAVERSE = &h000020
Const FILE_READ_ATTRIBUTES = &h000080
Const FILE_READ_CONTROL = &h020000
Const FOLDER_LIST_DIRECTORY = &h000001
Const FILE_READ_EA = &h000008
Const FILE_SYNCHRONIZE = &h100000
Const FILE_WRITE_ATTRIBUTES = &h000100
Const FILE_WRITE_DAC = &h040000
Const FOLDER_ADD_FILE = &h000002
Const FILE_WRITE_EA = &h000010
Const FILE_WRITE_OWNER = &h080000
Const WBEM_RETURN_IMMEDIATELY = &h10
Const WBEM_FORWARD_ONLY = &h20
Dim objWMIService, objItem
Dim strComputer
Dim arrComputers
Dim colItems
Sub ReadDescriptor(strPath)
Dim objFolderSecuritySettings, objSD, objACE
Dim arrACEs
Dim intControlFlags
Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strPath & "'")
objFolderSecuritySettings.GetSecurityDescriptor objSD
intControlFlags = objSD.ControlFlags
If intControlFlags AND SE_DACL_PRESENT Then
arrACEs = objSD.DACL
For Each objACE in arrACEs
WScript.StdOut.Write "\" & objACE.Trustee.Domain & "\" & objACE.Trustee.Name
If objACE.AccessMask AND FILE_ALL_ACCESS Then
WScript.StdOut.Write " FILE_ALL_ACCESS "
End If
If objACE.AccessMask AND FOLDER_ADD_SUBDIRECTORY Then
WScript.StdOut.Write "FOLDER_ADD_SUBDIRECTORY "
End If
If objACE.AccessMask AND FILE_DELETE Then
WScript.StdOut.Write "FILE_DELETE "
End If
If objACE.AccessMask AND FILE_DELETE_CHILD Then
WScript.StdOut.Write "FILE_DELETE_CHILD "
End If
If objACE.AccessMask AND FOLDER_TRAVERSE Then
WScript.StdOut.Write "FOLDER_TRAVERSE "
End If
If objACE.AccessMask AND FILE_READ_ATTRIBUTES Then
WScript.StdOut.Write "FILE_READ_ATTRIBUTES "
End If
If objACE.AccessMask AND FILE_READ_CONTROL Then
WScript.StdOut.Write "FILE_READ_CONTROL "
End If
If objACE.AccessMask AND FOLDER_LIST_DIRECTORY Then
WScript.StdOut.Write "FOLDER_LIST_DIRECTORY "
End If
If objACE.AccessMask AND FILE_READ_EA Then
WScript.StdOut.Write "FILE_READ_EA "
End If
If objACE.AccessMask AND FILE_SYNCHRONIZE Then
WScript.StdOut.Write "FILE_SYNCHRONIZE "
End If
If objACE.AccessMask AND FILE_WRITE_ATTRIBUTES Then
WScript.StdOut.Write"FILE_WRITE_ATTRIBUTES "
End If
If objACE.AccessMask AND FILE_WRITE_DAC Then
WScript.StdOut.Write "FILE_WRITE_DAC "
End If
If objACE.AccessMask AND FOLDER_ADD_FILE Then
WScript.StdOut.Write "FOLDER_ADD_FILE "
End If
If objACE.AccessMask AND FILE_WRITE_EA Then
WScript.StdOut.Write "FILE_WRITE_EA "
End If
If objACE.AccessMask AND FILE_WRITE_OWNER Then
WScript.StdOut.Write "FILE_WRITE_OWNER "
End If
next
Else
WScript.StdOut.Write "No DACL present in security descriptor" & vbCrLf
End If
End Sub
'
' Main Code
'
Const INPUT_FILE_NAME = "C:\tools\Computers.txt"
Const FOR_READING = 1
Dim objFSO
Dim objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
strComputer = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputer, vbCrLf)
For Each strComputer In arrComputers
WScript.Echo strComputer
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Share WHERE Type=0", "WQL",_
WBEM_RETURN_IMMEDIATELY + WBEM_FORWARD_ONLY)
For Each objItem in colItems
WScript.StdOut.Write objItem.Path & " "
ReadDescriptor objItem.Path
WScript.Echo
Next
Set objWMIService = Nothing
On Error Goto 0
Next