Have Fun! : )
The Output...
PS D:\data\scripts\ps-notes> ./MailStats.ps1 Start: 13:09:57.0831 Host Drive Size GB Free GB =============== ===== ========== ========== AMnotes01 F: 150.00 28.19 Mailbox Size MB Doc Count =============== ========== ========== mail1.box 12,336 6 mail2.box 4,884 4 mail3.box 4,727 4 mail4.box 4,651 4 --------------- ---------- ---------- Totals 26,598 4 Elapsed Time: 00:00:17.0125
The Code...
## MailStats.ps1 ## First Code 07:05:20.0415 ## initial runtime 00:00:48.0165 ## $dtStart = (get-date) "Start: "+($dtStart.Hour.ToString()).PadLeft(2,"0")+":"+($dtStart.Minute.ToString()).PadLeft(2,"0")+":"+($dtStart.Second.ToString()).PadLeft(2,"0")+"."+($dtStart.Millisecond.ToString()).PadLeft(4,"0") $StartPath = Get-Location ## Vars to set $LocalDataDir = 'C:\Program Files (x86)\IBM\Lotus\Notes\Data' ## your local Notes data dir $DominoServiceName = 'UserSMTPgw01/SRV/AM/MyCompany' ## your Notes/Domino Server $HostName = 'AMnotes29' ## the host name that the Domino service runs on $HostDataDir = 'f$\notes\data\' ## the rest of the unc path to the Domino services' data dir $HostDataDrive = 'F:' ## drive where the Domino services' data dir is on $UNCMailboxPath = '\\'+$HostName+'\'+$HostDataDir+'mail*.box' $MailBoxes = Get-ChildItem -Path $UNCMailboxPath Set-Location $LocalDataDir $Notes = New-Object -ComObject Lotus.NotesSession $Notes.Initialize() $HostMBDisk = Get-WmiObject Win32_LogicalDisk -ComputerName $HostName | where {$_.DeviceID -eq 'F:'} | Select-Object Size,FreeSpace Write-output "" Write-Output "Host Drive Size GB Free GB" Write-Output "=============== ===== ========== ==========" Write-Output ( $HostName.PadRight(15)+' ' ` +$HostDataDrive.PadLeft(5)+' ' ` +("{0:N2}" -f ($HostMBDisk.Size/1GB)).ToString().PadLeft(10)+' ' ` +("{0:N2}" -f ($HostMBDisk.FreeSpace/1GB)).ToString().PadLeft(10)) Write-output "" Write-Output " Mailbox Size MB Doc Count" Write-Output " =============== ========== ==========" $TotSize = 0 $TotDocs = 0 foreach ($mailbox in $MailBoxes) { $dbMB = $Notes.GetDatabase($DominoServiceName, $mailbox.name.ToString(), 1) if ($dbMB -ne $null) { $colAllDocs = $dbMB.AllDocuments Write-output ( " " ` +$mailbox.name.ToString().PadRight(15)+' ' ` +("{0:N0}" -f ($dbMB.Size/1MB)).ToString().padleft(10)+' ' ` +($colAllDocs.Count.ToString().padleft(10))) $TotSize = $TotSize + $dbMB.Size $TotDocs = $colAllDocs.Count $colAllDocs = $null } else { $strStatus = 'No Mailbox' } $dbMb = $null } Write-Output " --------------- ---------- ----------" Write-output ( ' Totals ' ` +("{0:N0}" -f ($TotSize/1MB)).ToString().padleft(10)+' ' ` +($TotDocs.ToString().padleft(10))) Write-output "" Set-Location $StartPath $dtDiff = (New-Timespan -Start $dtStart -End (Get-Date)) "Elapsed Time: "+($dtDiff.Hours.ToString()).PadLeft(2,"0")+":"+($dtDiff.Minutes.ToString()).PadLeft(2,"0")+":"+($dtDiff.Seconds.ToString()).PadLeft(2,"0")+"."+($dtDiff.Milliseconds.ToString()).PadLeft(4,"0") $TotSize = $null $TotDocs = $null $dbMB = $null $Notes = $null $StartPath = $null $dtStart = $null