Question : Script that can scan each machine in the txt file and mail me the details individually on which share has everone full access.?

Hi,

Script that can scan each machine in the txt file and mail me the details individually on which share has everone full access.?
Is there a way to do this?

So i can forward the same mail to the employer to restrict the same.

Machine name
Folder name that has full access

Regards
Sharath

Answer : Script that can scan each machine in the txt file and mail me the details individually on which share has everone full access.?

try this:
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:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Dim boolCode : Dim a : Dim b
Dim objshell : Set objshell = CreateObject("WScript.Shell")
Dim objfso : Set objfso = CreateObject("Scripting.FileSystemObject")
' change the path to your list text file
Dim objlist : Set objlist = objfso.OpenTextFile("\\dc\share\list.txt", ForReading)
' change the path to the path to save your report 
Dim objreport : Set objreport = objfso.OpenTextFile("\\dc\share\report.txt", ForWriting)
 
Do Until objlist.AtEndOfStream
	           
	Dim strComputer : strComputer = objlist.ReadLine
	         
	objreport.WriteLine strComputer
	objreport.writeline "***************"
	         
	If Ping(strComputer) = True Then
		On Error Resume Next
		Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & _
		strComputer & "\root\cimv2")
		If Err.Number <> 0 Then
			Err.Clear
			objreport.WriteLine "Unable to connect to " & strComputer & vbcrlf
			On Error GoTo 0
		Else
			On Error GoTo 0
		End If
				
		On Error Resume Next
		Dim colItems : Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalShareSecuritySetting")
		If Err.Number <> 0 Then
 	   Err.Clear
			objreport.WriteLine "Probably Not Enoughf Permission On " & strComputer & vbcrlf
		Else
			On Error goto 0
		End If	
		Dim objItem, intRtn, wmiSecurityDescriptor
		Dim colDACLs, objACE, objUserGroup, strPermission
		For Each objItem In colItems
			'objreport.WriteLine "Share Name:  " & objItem.Name
			                                       
			intRtn = objItem.GetSecurityDescriptor(wmiSecurityDescriptor)
			                                   
			colDACLs = wmiSecurityDescriptor.DACL
			                                       
			For Each objACE In colDACLs
				Set objUserGroup = objACE.Trustee
				If UCase(objUserGroup.Name) = "EVERYONE" Then 
				a = true                                                          
			'	objreport.WriteLine vbTab & "User/Group that has access:  " & UCase(objUserGroup.Name)
				End if
				                                                           
				Select Case objACE.AccessMask
					Case 1179817 strPermission = "READ"
					Case 1245631 strPermission = "CHANGE"
					Case 2032127 strPermission = "FULL CONTROL"
				End Select
				If strPermission = "FULL CONTROL" Then 
				b = true                                                          
				'	objreport.WriteLine vbTab & "Permission:  " & strPermission & VbCrLf
				End If	
				If a = True And b = True Then
				objreport.WriteLine "Share Name:  " & objItem.Name
				objreport.WriteLine vbTab & "User/Group that has access:  " & UCase(objUserGroup.Name)
				objreport.WriteLine vbTab & "Permission:  " & strPermission & vbCrLf
				End if
                                a = false
                                b = false 
			Next
		Next
	Else
		objreport.WriteLine "Unable to ping " & strComputer & VbCrLf
	End If
Loop
objreport.Close
' change the mailsend syntax as you need
objshell.Run("MAILSEND -d (Email service) -smtp 192.168.0.200 -t (youremail) -f (Email again) -sub netuser") 
WScript.Echo "Finished"
 
Function Ping(strComputer)
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function
Open in New Window Select All
Random Solutions  
 
programming4us programming4us