Getting Exchange 2016 DB/Transaction Log Sizes

Getting Exchange 2016 DB/Transaction Log Sizes

Logs can be the bain of any Exchange Environment when things aren’t going well…

I needed to keep track of one I was looking after so after seeing the following post and it not working for me:

http://practicalkungfu.net/2012/12/22/get-exchange-2010-transaction-log-folder-sizes-with-powershell/

 

I created my own version to get them from an environment where all DBs where held in mount points.

[CC lang=’powershell’]

# Get DB/Transaction Log Sizes for Exchange 2016.

if¬†(!(Get-PSSnapin¬†| where {$_.Name¬†-eq¬†“Microsoft.Exchange.Management.PowerShell.E2010”}))
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue
}

Write-Progress¬†-Activity¬†“Exchange Servers”¬†-status¬†“Collecting Exchange Servers info”
$ExchangeServers = Get-ExchangeServer -ErrorAction SilentlyContinue

Write-Progress¬†-Activity¬†“Databases”¬†-status¬†“Collecting Databases info”
$Databases = Get-mailboxdatabase | Select Name,LogFolderPath,ServerNAme | Sort-Object Name

$trupath = @()
$databases | ForEach-ObJect{
$logpath = $_.LogFolderPath.ToString()
$logserver = $_.Servername.ToString()
$trupath¬†+=¬†$logpath¬†-replace¬†“C:\\”,¬†“\\$logserver\c$\”
}

ForEach($pat in $trupath){
$size¬†=¬†“{0:N2} MB”¬†-f¬†((GCI¬†$pat¬†-recurse¬†|Measure-Object¬†-Property¬†Length¬†-Sum¬†-ErrorAction¬†Stop).Sum / 1MB)
Write-Host¬†“$Pat`t $size”
}

[/CC]

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *