TDM
Fri Oct 07 10:27:35 CDT 2005
<juicy_killa@hotmail.com> wrote in message
news:1128673126.688383.12520@g14g2000cwa.googlegroups.com...
> Hey all,
>
> I need to write a simple script that will enumerate all of the shares
> on our file servers, and the number of user accounts with permissions
> to each share. The purpose is to evaluate which shares can be deleted
> to free up disk space by deleting shares with fewer than 10 users.
>
> I have found some simple VBScript and JScript code that will enumerate
> all of the shares on a given server like so:
>
> ' Begin code snippit
> set objFs = GetObject("WinNT://" & strServer &
> "/LanmanServer,FileService")
>
> For Each objShare In objFs
> strList = strList & vbCr & LCase(objShare.name) & vbTab &
> UCase(objShare.Description)
> Next
> ' End code snippit
>
> My problem is that I need to know what other class members/methods are
> available for the "FileService" (instanced as objFs) In the example
> above, we use objShare.name and objShare.Description during the loop.
> In which documentation would I find a list of the other class
> methods/variables for objShare? I am at wits end, just trying to find
> the documentation
>
> Thanks in advance
> Tim
>
You might also want to explore Win32_Share using WMI. I trust your servers
are Win2K or greater ?, and the user running this script has admin rights
on the servers ? I grabbed this function from a much larger script I wrote
to look for openshares on the network. It also contains a function to
enumerate
the user accounts and access rights for each user per share. If interested,
I can
send via e-mail if you like. Again, using WMI.
Function getNetShares(strHostName)
Dim objWMIService
Dim colShares
Dim objShare
Dim strMyMsg
On Error Resume Next
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,authenticationLevel=Default}!\\" &
strHostName & "\root\cimv2")
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share", , 48)
For Each objShare in colShares
strMyMsg = "Share Name: " & vbTab & objShare.Name & vbCrLf
strMyMsg = strMyMsg & "Share Caption: " & vbTab & objShare.Caption &
vbCrLf
strMyMsg = strMyMsg & "Share Path: " & vbTab & objShare.Path & vbCrLf
strMyMsg = strMyMsg & "Share Type: " & vbTab &
getShareType(objShare.Type) & vbCrLf
WScript.Echo strMyMsg
Next
Set objWMIService = Nothing
Set colShares = Nothing
getNetShares = Err.Number
End Function
My personal favorite for finding what you request in WMI is the WMI object
browser
from M$. Watch for line wrap ...
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6430F853-1120-48DB-8CC5-F2ABDC3ED314
TDM