{"id":957,"date":"2020-02-18T12:44:27","date_gmt":"2020-02-18T12:44:27","guid":{"rendered":"http:\/\/ihni.uk\/?p=957"},"modified":"2020-02-18T12:44:27","modified_gmt":"2020-02-18T12:44:27","slug":"getting-exchange-2016-db-transaction-log-sizes","status":"publish","type":"post","link":"https:\/\/ihni.uk\/?p=957","title":{"rendered":"Getting Exchange 2016 DB\/Transaction Log Sizes"},"content":{"rendered":"<p>Logs can be the bain of any Exchange Environment when things aren\u2019t going well\u2026<!--more--><span id=\"more-977\"><\/span><\/p>\n<p>I needed to keep track of one I was looking after so\u00a0after seeing the following post and it not working for me:<\/p>\n<p>http:\/\/practicalkungfu.net\/2012\/12\/22\/get-exchange-2010-transaction-log-folder-sizes-with-powershell\/<\/p>\n<p>&nbsp;<\/p>\n<p>I created my own version to get them from an environment where all DBs where held in mount points.<\/p>\n<div>\n<div id=\"highlighter_744613\" class=\"syntaxhighlighter powershell\">\n<div class=\"toolbar\">[CC lang=\u2019powershell\u2019]<\/div>\n<\/div>\n<div>\n<p># Get DB\/Transaction Log Sizes for Exchange 2016.<\/p>\n<p>if\u00a0(!(Get-PSSnapin\u00a0| where {$_.Name\u00a0-eq\u00a0&#8220;Microsoft.Exchange.Management.PowerShell.E2010&#8221;}))<br \/>\n{<br \/>\nAdd-PSSnapin\u00a0Microsoft.Exchange.Management.PowerShell.E2010\u00a0-ErrorAction\u00a0SilentlyContinue<br \/>\n}<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Exchange Servers&#8221;\u00a0-status\u00a0&#8220;Collecting Exchange Servers info&#8221;<br \/>\n$ExchangeServers\u00a0=\u00a0Get-ExchangeServer\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Databases&#8221;\u00a0-status\u00a0&#8220;Collecting Databases info&#8221;<br \/>\n$Databases\u00a0=\u00a0Get-mailboxdatabase\u00a0| Select Name,LogFolderPath,ServerNAme |\u00a0Sort-Object\u00a0Name<\/p>\n<p>$trupath\u00a0= @()<br \/>\n$databases\u00a0|\u00a0ForEach-ObJect{<br \/>\n$logpath\u00a0=\u00a0$_.LogFolderPath.ToString()<br \/>\n$logserver\u00a0=\u00a0$_.Servername.ToString()<br \/>\n$trupath\u00a0+=\u00a0$logpath\u00a0-replace\u00a0&#8220;C:\\\\&#8221;,\u00a0&#8220;\\\\$logserver\\c$\\&#8221;<br \/>\n}<\/p>\n<p>ForEach($pat\u00a0in\u00a0$trupath){<br \/>\n$size\u00a0=\u00a0&#8220;{0:N2} MB&#8221;\u00a0-f\u00a0((GCI\u00a0$pat\u00a0-recurse\u00a0|Measure-Object\u00a0-Property\u00a0Length\u00a0-Sum\u00a0-ErrorAction\u00a0Stop).Sum \/ 1MB)<br \/>\nWrite-Host\u00a0&#8220;$Pat`t $size&#8221;<br \/>\n}<\/p>\n<\/div>\n<div>[\/CC]<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Logs can be the bain of any Exchange Environment when things aren\u2019t going well\u2026<\/p>\n","protected":false},"author":1,"featured_media":988,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,19,11],"tags":[],"class_list":["post-957","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-powershell","category-scripts"],"jetpack_featured_media_url":"https:\/\/ihni.uk\/wp-content\/uploads\/2020\/02\/Powershell.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts\/957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=957"}],"version-history":[{"count":0,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts\/957\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/media\/988"}],"wp:attachment":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}