Sub Initialize

' *** Change the following two values before running the agent ***

Const SERVERNAME = "" ' eg. DevServer1

Const FILENAME = "c:\temp\ServerScan.csv" ' eg. c:\temp\serverscan.csv

'*****

On Error Goto errorhandler

Const OPENED = "Opened"

Const NOTOPENED = "Not opened"

Dim dbdir As New NotesDbDirectory( SERVERNAME )

Dim db As NotesDatabase

Dim i As Integer

' get all databases and templates on the server

' if you only want databases then change TEMPLATE_CANDIDATE to ???

' if you only want templates then change TEMPLATE_CANDIDATE to ???

Set db = dbdir.GetFirstDatabase(TEMPLATE_CANDIDATE)

'Open a new CSV file and write the column headers

Dim fileNum As Integer

fileNum% = Freefile()

Open FILENAME For Output As fileNum%

Write #fileNum%, "Title", "File name", "File path", "Replica Id", "Design template name", "Template name", "Database size", "Opened?", "Date created", "Date last modified", "Full Text Indexed", "Percent used", "In directory catalog"

' Loop through all databases on the server and write information to the text file

While Not(db Is Nothing)

i = i + 1

Print "Processing database #" & i

' If the database can be opened the write out all database properties

' otherwsie only write out those properties which we can get without having to open the database.

If openDb( db ) Then

Write #fileNum%, db.Title, db.FileName, db.FilePath, db.ReplicaID, db.DesignTemplateName, db.TemplateName, db.Size, OPENED, Cstr(db.Created), Cstr(db.LastModified), Cstr(db.IsFTIndexed), db.PercentUsed, Cstr(db.IsDirectoryCatalog)

Else

Write #fileNum%, db.Title, db.FileName, db.FilePath, db.ReplicaID, db.DesignTemplateName, db.TemplateName, db.Size, NOTOPENED,"","","","",""

End If

Set db = dbdir.GetNextDatabase

Wend

' Close the CSV file

Close fileNum%

Goto ExitSub

errorhandler:

Messagebox "An error has occured: " & Error$

Resume ExitSub

ExitSub:

End Sub

Function OpenDb( p_db As Notesdatabase) As Boolean

' Only return True if the database is opened ok.

OpenDb = False ' Assume failure

Dim db As New notesdatabase("", "")

On Error Goto openerror

If p_db.Open("", "" ) Then

OpenDb = True ' Db opened ok so return True to caller

End If

Goto ExitFunction

openerror:

Resume ExitFunction

ExitFunction:

End Function