I thought that this would be an easy script to find, but surprising there are no complete script to be found. I found the following powershell script in the respository
It works and lists the shares, but it does not product the path of the share!
Found another helpful posts for VBScript version here:
It works but for some reasons the security permissions are not correct
The closest I find is this:
Works well BUT it again does not list the path of share. Why in the world would I not want to know where a share path is?
So I have to clobber the last 2 VBScript together to produce a functional one that I need. Credits to the authors in the link above:
Dim strComputer : strComputer = "." Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & _ strComputer & "\root\cimv2") Dim colItems : Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalShareSecuritySetting") Dim objItem, intRtn, wmiSecurityDescriptor Dim colDACLs, objACE, objUserGroup, strPermission, colShr, objShr For Each objItem In colItems WScript.Echo "Share Name: " & objItem.Name Set colShr = objWMIService.ExecQuery("Select * from win32_share where name='" & objItem.Name & "'") For Each objShr in colShr WScript.Echo "Share Path: " & objShr.Path Next intRtn = objItem.GetSecurityDescriptor(wmiSecurityDescriptor) colDACLs = wmiSecurityDescriptor.DACL For Each objACE In colDACLs Set objUserGroup = objACE.Trustee WScript.Echo vbTab & "User/Group that has access: " & UCase(objUserGroup.Name) Select Case objACE.AccessMask Case 1179817 strPermission = "READ" Case 1245631 strPermission = "CHANGE" Case 2032127 strPermission = "FULL CONTROL" End Select WScript.Echo vbTab & "Permission: " & strPermission & VbCrLf Next Next