get-PublicFolderReplicaItemCounts.ps1 example

This script queries all the replicas of a public folder (or PF tree) and provides an item count for each replica found. Will work for replicas homed on Microsoft Exchange Server 2003/2007/2010. Please note appropriate permissions are required for a successful scan.

 
 
 
 
 
4 Star
(5)
2,820 times
Add to favorites
Exchange
12/29/2011
E-mail Twitter del.icio.us Digg Facebook
  • Has anyone else managed to get this code to work?
    2 Posts | Last post November 15, 2012
    • I can't get it to work. I establish a pssession to an Exchange 2010 server, and run the code specifying a path to one of our public folders (whose replica is on an Exchange 2003 server).
      
      where it's getting stuck is:
      
      $pfCollection = Get-PublicFolder $Path -ErrorAction silentlycontinue | Select identity,replicas,@{Name="LegPFDN"; Expression = {$_.identity.legacyDistinguishedName}}
      
      I understand the rename hash table part, but $_.identity.legacyDistinguishedName???
      
      When I do this (note, full path entered, but just not shown here):
      $path = '\...\...\...\...\cluster'
      Get-PublicFolder $Path|fl
      
      I can see all the properties of the public folder, including identity and replicas however, there is no identity.legacyDistinguishedName property for the object, nor does the object have a legacyDistinguishedName property. 
      
      The only properties for the found object are:
      
      RunspaceId                     
      AgeLimit                       
      EformsLocaleId                 
      EntryId                        
      HasSubFolders                  
      HiddenFromAddressListsEnabled  
      IssueWarningQuota              
      LocalReplicaAgeLimit           
      MailEnabled                    
      MaxItemSize                    
      Name                           
      ParentPath                     
      PerUserReadStateEnabled        
      ProhibitPostQuota              
      Replicas                       
      ReplicationSchedule            
      RetainDeletedItemsFor          
      UseDatabaseAgeDefaults         
      UseDatabaseQuotaDefaults       
      UseDatabaseReplicationSchedule 
      UseDatabaseRetentionDefaults   
      FolderType                     
      HasRules                       
      HasModerator                   
      Identity                       
      MapiIdentity                   
      OriginatingServer              
      IsValid                        
      
      The legacyDistinguishedName is required for the following WMI query, but it is not exposed from the initial Get-PublicFolder commandlet.
      
      Has anyone else encountered this problem?
    • FingerPainter, I'm am not sure why you are unable to see the LegacyDistinguishedName sub-property of the Identity property.  In your example, if you store your get-publicfolder cmdlet call to a variable, such as: "$t = get-publicfolder $path", you should be able to enumerate the methods and properties with a: "$t.identity | get-member" and you should see "LegacyDistinguishedName Property System.String LegacyDistinguishedName {get;}" returned in the list.  The public folder identity is of type Microsoft.Exchange.Data.Mapi,PublicFolderID.  In MSDN, we have the following property reference: http://msdn.microsoft.com/en-us/library/microsoft.exchange.data.mapi.folderid.legacydistinguishedname.aspx
  • Script not working.
    2 Posts | Last post November 15, 2012
    • I was able to run the script on a small PF with 2 levels with no issues.  When running the script from the root "\" - recurse the cmd looks like its running, i let is sit for over 12 hours and didn't get any output.  IS there a way to run this with multiple sub folders?
    • Adeel, glad the script is working for you! I would imagine that the hang you are encountering is because the script is churning through the entire IPM subtree hierarchy from the root, and depending on the size of your hierarchy the delay could be huge.  I don't have any provisions in the code to batch or chunk portions of a tree automatically.  I would suggest simply running the script against the top level folders under the root (or perhaps a bit deeper if those subtrees are also large) separately and then consolidate the results if needed.