Powershell Needful Things put that in your pipeline

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
Filed under: exchange Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.