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 and Contact Numbers 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. I am struggling find a way to include only .doc or .docx files.
Any help would be greatly appreciated.
Set objContainer = GetObject("LDAP://OU=My OU,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.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