Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to get folder owners

Status
Not open for further replies.

Dukester0122

IS-IT--Management
Mar 18, 2003
587
US
I need a script so it'll give me the owners of certain folders/subfolders.
 
What have YOU tried so far and where in YOUR code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This script is working but only can look at one folder. I have around 300+ subfolders and want the script to loop and look at each folder:

strFolderName = "c:\Billing\Invoices"
Set objWMIService = GetObject("winmgmts:")
Set objFolderSecuritySettings = _
objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)

If intRetVal = 0 Then
WScript.Echo "Owner: " & objSD.Owner.Domain & "\" & objSD.Owner.Name
Else
WScript.Echo "Couldn't retrieve security descriptor."
End If
 
I'm not a programmer so looking at that link doesn't help me. I need somebody who can point me what's missing and where to insert in the script.

I got the script on a VB script site.

tks.
 
Set FSO = CreateObject("Scripting.FileSystemObject")

ShowSubfolders FSO.GetFolder("C:\WINDOWS")


Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objWMIService = GetObject("winmgmts:")
Set objFolderSecuritySettings = _
objWMIService.Get("Win32_LogicalFileSecuritySetting='" & Folder & "'")
intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)

If intRetVal = 0 Then
WScript.Echo "Owner: " & objSD.Owner.Domain & "\" & objSD.Owner.Name
Else
WScript.Echo "Couldn't retrieve security descriptor."
End If
ShowSubFolders Subfolder
Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top