Submitted By: Kent Finkle

Retrieves the total size of and the number of items in the Microsoft Outlook contacts folder.

PowerShell
Edit|Remove
$comments = @'
Script name: Get-OutlookFolderSize.ps1
Created on: Tuesday, July 24, 2007
Author: Kent Finkle
Purpose: How can I use Windows Powershell to
Get Total Size and Number of Items in an Outlook Folder?
'@
 
$olFolderContacts = 10
 
$o = new-object -comobject outlook.application
 
$n = $o.GetNamespace("MAPI")
 
$objFolder = $n.GetDefaultFolder($olFolderContacts)
 
$colItems = $objFolder.Items
 
Write-Host("No. of items in Inbox: " + $colItems.Count)
 
foreach ($objItem in $colItems) { 
    $intSize += $objItem.Size
}
 
$size = [math]::truncate($intSize/1024)
 
Write-Host("Size of Contacts: " + $size + " KB")