Audit Home Directories Using WSH

By ServerWatch Staff (Send Email)
Posted Aug 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.........

ver 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.

 

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
    LogResults()
       
Next

   
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)
    strTextStream.WriteLine(vbcrlf)
    strTextStream.Close

End Sub


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

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.