Website-Icon Granikos GmbH & Co. KG

Get Legacy Public Folder Size

When you are dealing with legacy public folders and you are still using Exchange Server 2007 you might be interested in the overall size of the data hosting in your public folder hierarchy.

The following script calculates the public folder size based on the public folder statistics output provided by Exchange Server 2007.

# Server name hosting legacy public folders
$Server = 'PUBLICFOLDERSERVER'

# Fetch legacy public folder statistics
$Folders = Get-PublicFolderStatistics -server $Server | Where-Object {($_.TotalItemSize -ne "0B")}  
$TotalBytes = 0

# Let's do some string manipulation stuff
ForEach ($Item in $Folders) {
  $TotalItemSize = $Item.TotalItemSize
  $TotalItemSize = [string]$TotalItemSize
  if ( ($TotalItemSize.contains('KB')) ) {
      $TotalItemSize = $TotalItemSize -Replace ('KB','')
      $TotalItemSize = [int]$TotalItemSize * 1024  
  }
  $TotalItemSize = $TotalItemSize -Replace ('B','')
  $TotalBytes = [long]$TotalItemSize + [long]$TotalBytes}

# Output as GB 
[math]::round($TotalBytes/1Gb, 2)

Enjoy.

Kurz-URL | Short URL: https://granikos.eu/go/QGtk
Die mobile Version verlassen