Audit Home Directories Using WSH

Audit Home Directories Using WSH

August 29, 2000

by John Loomes

Ever wanted a quick and easy way to log information about your users home directories? I wrote this script to audit Lotus Notes data stored in home directories for thousands of users, but you could adapt it for virtually any purpose. You point the script at the root of the drive containing the home directories, and it walks through the tree, recording information as it goes, in this case, the paths to certain files and the size of the Notes cache. The data collected is logged for later review. We used this information to get an idea of how much disk space Notes cache files were taking up, with a view to writing another script to clean them up. Feel free to experiment with this and adapt it for your own purpose.........


Dim fso, szRoot, szFolders, szUserFolder
Dim szNotesPath, szNotesNewPath
Dim szNotesDatadir, szNotesDataSize
Dim szNotesIni, szNotesCacheSize, szNotesCache

CONST szPath = "\\MYSERVER\d$\Data\Users"

Set fso = CreateObject("Scripting.FileSystemObject")

Set szRoot = fso.GetFolder(szPath)

Set szFolders = szRoot.SubFolders

For each folder in szFolders

    szNotesPath = ""
    szUserFolder = ""
    szNotesNewPath = ""
    szNotesDataSize = ""
    szNotesDataDir = ""
    szNotesIni = ""
    szNotesCache = ""
    szNotesCacheSize = ""   
    szUserFolder = Folder.Name
    If fso.FolderExists(szPath&"\"&Folder.Name&"\Lotus\Notes4") Then
        szNotesPath = szPath&"\"&Folder.Name&"\Lotus\Notes4"
        Set szNotesDataDir = fso.GetFolder(szNotesPath&"\Data")
        szNotesDataSize = szNotesDataDir.Size
        If fso.FileExists (szPath&"\"&Folder.Name&"\Lotus\Notes4\Data\Cache.dsk") Then
            Set szNotesCache = fso.GetFile(szNotesPath&"\Data\Cache.dsk")
            szNotesCacheSize = szNotesCache.Size
        End if
        If fso.FileExists (szPath&"\"&Folder.Name&"\Lotus\Notes4\Notes.ini") Then
            szNotesIni = szPath&"\"&Folder.Name&"\Lotus\Notes4\Notes.ini"
        End if
    End if
    If fso.FolderExists(szPath&"\"&Folder.Name&"\Notes4") Then
        szNotesNewPath = Folder.Name&"\Notes4"
    End if

Sub LogResults()

    CONST szLogFile = "\\MYSERVER\logs\NotesAudit\ServerLog.txt"

    Dim strTextStream, objFS
    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set strTextStream = objFS.OpenTextFile(szLogFile, 8, true)
    strTextStream.WriteLine(szUserFolder & vbTab & szNotesPath & vbtab & szNotesDataSize & vbtab & szNotesCacheSize & vbtab & szNotesNewPath)

End Sub

Please note that this is provided 'as is' with no warranties i.e. dont blame me if it all goes wrong!