Just a quick post for Saturday. If you’d like to check your OAB sizes, here’s a quick script that allows you to do so quickly and easily. This could be useful to keep track of the space used over time, check all OAB replicas are the same size or to quickly check that the sizes have changes after manually running the Update-OfflineAddressBook cmdlet.
There’s few pre-requisites, You need to be on a machine that has at least read access to the C$ shares on the Client Access Servers hosting the OAB folders along with access to get information about the Offline Address Book and OAB Virtual Directories.
Once those pre-reqs are fulfilled, usage is simple:
1 | .\Get-OABSizes.ps1 |
The output should look similar to this:
You can of course pipe the output and filter it, i.e.
1 |
The Get-OABSizes.ps1 Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # # Get-OABSizes.ps1 # Fetches the total file size of each copy of each offline address book # # Steve Goodman # # Retrieve all OABs $OABs = Get-OfflineAddressBook # Cycle through each OAB foreach ($OAB in $OABs) { # Cycle through each OAB Virtual Directory for the current OAB foreach ($OABVirtualDirectory in $OAB.VirtualDirectories) { # Get the actual OAB Virtual Directory properties $OABVirtualDirectory = Get-OabVirtualDirectory -Identity $OABVirtualDirectory; # Retrieve the folder local to the CAS that hosts the OAB, and append the Guid of this OAB $LocalOABPath = "$($OABVirtualDirectory.Path)\$($OAB.Guid)"; # Get the UNC path used to get to the hidden C$ share on the CAS $BaseUNCPath = "\\$($OABVirtualDirectory.Server)\C$"; # Replace the local path with the UNC path to the CAS server $UNCOABPath = $LocalOABPath.Replace("C:",$BaseUNCPath); # Get the directory listing of the folder hosting the OAB $OABItems = Get-ChildItem -Path $UNCOABPath # Calculate the total size of the folder hosting the OAB, in bytes [int]$TotalBytes = ($OABItems | Measure-Object -Property Length -Sum).Sum; # Convert the total size in bytes to kilobytes [int]$TotalKBytes = $TotalBytes/1024; # Build the output object for this copy of the OAB and output it $Output = New-Object Object $Output | Add-Member NoteProperty Server $OABVirtualDirectory.Server; $Output | Add-Member NoteProperty Name $OABVirtualDirectory.Name; $Output | Add-Member NoteProperty OABName $OAB.Name; $Output | Add-Member NoteProperty OABSizeKB $TotalKBytes; $Output } } |
Hope you find this useful.
Hello Steve, I found your script at https://gallery.technet.microsoft.com/office/Report-your-Exchange-a1aa535b. This is a nice piece of work, thank you for this!
Unfortunately, I found a small error when the OABs are located on another drive than C:.
I suggest following code:
# Retrieve UNC path to the CAS server and the folder local to the CAS that hosts the OAB, and append the Guid of this OAB
$OABPath = “\\$($OABVirtualDirectory.Server)\$($OABVirtualDirectory.Path)\$($OAB.Guid)”;
# Replace the local path : sign with the $ sign used in UNC paths
$OABPath = $OABPath.Replace(“:\”,”$\”);
Pingback: Tweets that mention Report your Exchange Offline Address Book Sizes using Powershell | Steve Goodman's Tech Blog -- Topsy.com