I am trying to put together a script that would query a particular OU within my organisation and achieve the following;
1. List all users within the OU.
2. Query Job Tiltles of those users.
3. Count all .doc or .docx files within each users home directory within the OU.
4. Export all information into an Excel document.
So far, I have the compiled the vbscript below to count all files within each home directory in the OU. Although this doesn't seem to reflect the actual word document count.
The sub-folders go quite deep, and I'm not sure this is drilling down through the entire tree.
Any help would be greatly appreciated.
------------------
Set FSO = CreateObject("scripting.filesystemobject")
Set objContainer = GetObject("LDAP://OU=MyOU,OU=User Accounts,DC=MyDomain,DC=co,DC=uk")
For Each M in objContainer
If M.homeDirectory <> "" Then
FileCnt = 0
ReturnFileCountUsingFSO M.homeDirectory, FileCnt
WScript.echo M.cn & " ; " & M.Title & " ; " & FileCnt & " Word documents 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
If fso.GetExtensionName(objFile.Path) = "doc" Or fso.GetExtensionName(objFile.Path) = "docx" then
Count = Count + 1
END IF
Next
Set f = Nothing
Set fld = Nothing
Set FSO = Nothing
End Function
--------------------------------------------------
Any help would be greatly appreciated.
1. List all users within the OU.
2. Query Job Tiltles of those users.
3. Count all .doc or .docx files within each users home directory within the OU.
4. Export all information into an Excel document.
So far, I have the compiled the vbscript below to count all files within each home directory in the OU. Although this doesn't seem to reflect the actual word document count.
The sub-folders go quite deep, and I'm not sure this is drilling down through the entire tree.
Any help would be greatly appreciated.
------------------
Set FSO = CreateObject("scripting.filesystemobject")
Set objContainer = GetObject("LDAP://OU=MyOU,OU=User Accounts,DC=MyDomain,DC=co,DC=uk")
For Each M in objContainer
If M.homeDirectory <> "" Then
FileCnt = 0
ReturnFileCountUsingFSO M.homeDirectory, FileCnt
WScript.echo M.cn & " ; " & M.Title & " ; " & FileCnt & " Word documents 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
If fso.GetExtensionName(objFile.Path) = "doc" Or fso.GetExtensionName(objFile.Path) = "docx" then
Count = Count + 1
END IF
Next
Set f = Nothing
Set fld = Nothing
Set FSO = Nothing
End Function
--------------------------------------------------
Any help would be greatly appreciated.