13May/110
Monitor the number of items in a list of Public Folders
You can use the following basic code, to monitor the number of items in a list of public folders.
My client has a number of workflow processes which rely on public folders, and sometimes if a process stops, the number of items in the public folder will increase. In this script, you can specify the subfolder name, in the root folder and all the folders in that folder will be listed, with the number of items in each.
Replace "folder name" with the name of you main folder that you wish to monitor.
This code uses Outlook to logon and read the folder information, so the account that you are logged onto Outlook with, requires atleast read permission in the public folders which you are monitoring.
$pf = "folder name"
$itemCount = @{Name="Count";expression={foreach-object {($pfroot.folders.Item($pf).folders.item($_.Name).items).count}}}
$pfroot = (new-object -com outlook.application).getNamespace("MAPI").Session.GetDefaultFolder(18)
$pfroot.folders.Item($pf).folders | select Name, $itemCount
$itemCount = @{Name="Count";expression={foreach-object {($pfroot.folders.Item($pf).folders.item($_.Name).items).count}}}
$pfroot = (new-object -com outlook.application).getNamespace("MAPI").Session.GetDefaultFolder(18)
$pfroot.folders.Item($pf).folders | select Name, $itemCount
Leave a comment