?
Solved

How to obtain a report on stale directories

Posted on 2012-09-17
4
Medium Priority
?
353 Views
Last Modified: 2012-09-18
We'd like to get a report on home directories that have not had any of their contents updated in over 120 days. These directories are all on the same Windows server and NTFS volume. Does anyone know how to do this?
0
Comment
Question by:tshearon
  • 2
4 Comments
 
LVL 1

Expert Comment

by:mrandal
ID: 38406833
I often use sfk command line utility for such stuff. If you are on the server, in the root directory containing all user home directories, type the following all in one line (or a batch file):
sfk list -nosub -justdirs . +run -quiet "sfk list -nohead -late=1 -tabs $qfile" -yes | sfk filter -replace "_\*__" +sort -reverse

Open in new window

Explanation: list all dir names of current directory. run a command on every dir name to list the most recent file showing date and absolute filename. change every filename to just the home folder path. sort all by date in reverse order.

This will create a tab separated list with date, time, and folder name, sorted with oldest home folders at list bottom.
0
 
LVL 60

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 38407337
Here's a fairly simple VBS script that should do the job.  You may want to tweak the output format.  Save as a VBS, and then run passing it two parms, the base folder name, and the number of days of age to report.  For example:

cscript //nologo EE27867622.vbs c:\temp 200

if you want to save the output to a file then do:

cscript //nologo EE27867622.vbs c:\temp 200 > report.txt

' Get folder name to scan from command line
If (WScript.Arguments.Count > 0) Then
  strDir = WScript.Arguments(0)
Else
  WScript.Echo "No base folder name specified."
  WScript.Quit
End If

' Get days old to display from command line
If (WScript.Arguments.Count > 1) Then
  intDays = CInt(WScript.Arguments(1))
Else
  WScript.Echo "Missing age (days) to report."
  WScript.Quit
End If

' Create file system object
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

' Access the base folder specified
Set objFolder = objFSO.GetFolder(strDir)

' Look at all subfolders and display of they meet the age criteria
For Each objSubFolder In objFolder.Subfolders
   If DateDiff("d", objSubFolder.DateLastModified, Now) > intDays Then 
      Wscript.Echo "Folder:[" & objSubFolder.Path & "], Age:[" & DateDiff("d", objSubFolder.DateLastModified, Now) & "] days"
   End If
Next

Open in new window

~bp
0
 
LVL 8

Author Closing Comment

by:tshearon
ID: 38410371
Thanks billprew. This is exactly what I wanted.
0
 
LVL 60

Expert Comment

by:Bill Prew
ID: 38410420
Great, glad that helped.

~bp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
It is a real story and is one of my scariest tech experiences. Most users think that IT experts like us know how to fix all computer problems. However, if there is a time constraint and you MUST not fail the task or you will lose your job, a simple …
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question