{"id":18,"date":"2019-01-03T01:06:16","date_gmt":"2019-01-03T06:06:16","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=18"},"modified":"2019-01-27T03:51:27","modified_gmt":"2019-01-27T08:51:27","slug":"getting-all-exchange-databases-listed-and-whether-or-not-they-are-on-their-preferred-node-or-not","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/01\/03\/getting-all-exchange-databases-listed-and-whether-or-not-they-are-on-their-preferred-node-or-not\/","title":{"rendered":"Getting all Exchange Databases listed and whether or not they are on their preferred node or not."},"content":{"rendered":"\n<p>This is a great one liner in PowerShell that will allow you to get a listing of all the databases for your Exchange Server environment. It will also tell you if those databases are on their preferred node in the DAG and whether they are actively mounted on that node. <\/p>\n\n\n\n<p>This is helpful to know if you have multiple database fail-overs and need to know which databases are where so that you can re-balance them&nbsp;properly. If you are in a large environment, this will help you get a handle on the issue and be able to remediate quickly.<\/p>\n\n\n<pre class=\"lang:PowerShell\" title=\"Get all Exchange Databases with Mount and Preferred Node Status\">Write-Host;Date;Write-Host;Get-MailboxDatabase -Status | Sort Name | ForEach {$db=$_.Name; $xNow=$_.Server.Name ;$dbown=$_.ActivationPreference | Where {$_.Value -eq 1}; Write-Host $db \"on\" $xNow \"Should be on\" $dbOwn.Key \"- STATUS:\" -NoNewLine -ForeGroundColor Yellow; If ( $xNow -ne $dbOwn.Key){Write-host \" NOT ON PREFERRED NODE\" -ForegroundColor Red -NoNewLine; } Else {Write-Host \" ON PREFERRED NODE\" -ForegroundColor Green -NoNewLine}; If ( $_.Mounted -ne \"True\"){Write-host \" & DISMOUNTED\" -ForegroundColor Red; } Else {Write-Host \" & MOUNTED\" -ForegroundColor Green}}<\/pre>\n\n\n\n<p><strong>Here&nbsp;is&nbsp;an&nbsp;example&nbsp;of&nbsp;the&nbsp;output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"538\" height=\"618\" src=\"http:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/01\/DBPSStatus.png\" alt=\"\" class=\"wp-image-20\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/01\/DBPSStatus.png 538w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/01\/DBPSStatus-261x300.png 261w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n\n\n\n<p>Now, that you have your listing of DBs and their status, you can run the following script from PowerShell to mount those DBs to their preferred nodes:<\/p>\n\n\n<pre class=\"lang:PowerShell\" title=\"Check DB status and Mount to Preferred Node if necessary\">Write-Host;Date;Write-Host;Get-MailboxDatabase -Status | Sort Name | ForEach {$db=$_.Name; $xNow=$_.Server.Name ;$dbown=$_.ActivationPreference | Where {$_.Value -eq 1}; Write-Host $db \u201con\u201d $xNow \u201cShould be on\u201d $dbOwn.Key -NoNewLine -ForeGroundColor Yellow; If ( $xNow -ne $dbOwn.Key){Write-host \u201d NOT ON PREFERRED NODE\u201d -ForegroundColor Red; Move-ActiveMailboxDatabase $db -ActivateOnServer $dbOwn.Key -confirm:$False -SkipClientExperienceChecks | ft -a -wr} Else {Write-Host \u201d ON PREFERRED NODE\u201d -ForegroundColor Green -NoNewLine}; If ( $_.Mounted -ne \"True\"){Write-host \" & DISMOUNTED\" -ForegroundColor Red; } Else {Write-Host \" & MOUNTED\" -ForegroundColor Green}}<\/pre>\n\n\n\n<p>Since SLA and remediation are big factors in reactive support, having these scripts help save the day when things get quirky in Exchange. Please comment and submit your scripts as well! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a great one liner in PowerShell that will allow you to get a listing of all the databases for your<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/01\/03\/getting-all-exchange-databases-listed-and-whether-or-not-they-are-on-their-preferred-node-or-not\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":161,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[15,14,9,8],"class_list":["post-18","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-powershell","tag-cmdlet","tag-database","tag-exchange","tag-powershell","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=18"}],"version-history":[{"count":3,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/18\/revisions\/165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/161"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}