This script is for reporting purposes.
It enumerates the members of a specified group and calculates the number of files that each user has on his/her homedirectory. It is especially useful when run from the scheduler.
Follow the next steps to run the script (no admin rights needed):
- open your favorite text editor
- copy and paste the script into the editor
- change the distinguished name of the group to your specific situation
- save the script (for example c:\temp\groupfilesonhomedirectory.vbs)
- open a command prompt
- go to “c:\temp”
- give “cscript groupfilesonhomedirectory.vbs” (without quotes) and enter
The script:
' Name : groupfilesonhomedirectory.vbs
' Description : script to count the number of files on homedirectory for groupmembers
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 26-01-2010
Set objGroup = GetObject("LDAP://CN=test,OU=test,DC=test,DC=org")
For Each M in objGroup.Members
If M.homeDirectory <> "" Then
FileCnt = 0
ReturnFileCountUsingFSO M.homeDirectory, FileCnt
WScript.echo M.cn & " ; " & M.homeDirectory & " ; " & FileCnt & " files on home directory"
End If
Next
Set objGroup = Nothing
Function ReturnFileCountUsingFSO(strPath, FileCnt)
On Error Resume Next
Set FSO = CreateObject("scripting.filesystemobject")
Set fld = FSO.GetFolder(strPath)
FileCnt = FileCnt + fld.Files.Count
For Each f In fld.SubFolders
ReturnFileCountUsingFSO f.path, FileCnt
Next
Set f = Nothing
Set fld = Nothing
Set FSO = Nothing
End Function
Recent Comments