Rehome-DatabaseActivationPreference.ps1

#Powershell #MsExchange

 

An update to an old script.  Essentially I have added a switch for activation preference, so you can fail all databases over to say Activation Preference #3.

 

Copy below and save to Rehome-DatabaseActivationPreference.ps1.  Then run say:

Rehome-DatabaseActivationPreference.ps1 –database database.* -ActivationPreference 3

 

PARAM([String]$Database = "*",
[Int]$ActivationPreference = 1)
Write-Host "Database:………….."$Database
Write-Host "ActivationPreference:.."$ActivationPreference "`n"

#Load the Exchange 2010 bits & bobs
$xPsCheck = Get-PSSnapin | Select Name | Where {$_.Name -Like "*Exchange*"}
If ($xPsCheck -eq $Null) {Write-Host "Loading Exchange Snapin"; Add-PsSnapin Microsoft.Exchange.Management.PowerShell.e2010}

Get-MailboxDatabase $Database | Sort Name | FOREACH { $db=$_.Name; $xNow=$_.Server.Name ;$dbown=$_.ActivationPreference| Where {$_.Value -eq $ActivationPreference}; Write-Host $db "on" $xNow "Should be on" $dbOwn.Key -NoNewLine; If ( $xNow -ne $dbOwn.Key){Write-host " WRONG" -ForegroundColor Red; Move-ActiveMailboxDatabase $db -ActivateOnServer $dbOwn.Key -confirm:$False}ELSE{Write-Host " OK" -Foregroundcolor Green}}

Comments

  1. Jeff Bergeron says:

    I like it. I am used to seeing $args to pass command line input. How does this work with Param?

Leave a Reply

%d bloggers like this: