Archive for December 2010
8
SCOM : Gateway Primary and Failover MS
4 Comments · Posted by Christopher Keyaert in OpsMgr / Scom
If you want to change the Primary MS of your gateway server or if you want to add a failover MS to it, on the technet library on Deploying Gateway Server in the Multiple Server, Single Management Group Scenario, the following commands will be presented :
1 2 3 4 | $primaryMS = Get-ManagementServer | where {$_.Name -eq 'corp-ms02.corp.contoso.local'} $failoverMS = Get-ManagementServer | where {$_.Name -eq 'corp-r2.corp.contoso.local'} $gatewayMS = Get-GatewayManagementServer | where {$_.Name -eq 'dmz01'} Set-ManagementServer -GatewayManagementServer: $gatewayMS -primarymanagementserver: $primaryMS -FailoverServer: $failoverMS |
When you run this command you have to be aware that when the current management server gets this update it will stop accepting connections from your gateway server (if it is not primary or failover management server in the new configuration). That could result in a orphaned gateway server, the gateway server is not allowed to communicate with any management server.
To avoid that, I wrote a little PowerShell Script that does all the task for you and avoid to have a orphaned gateway server. For writing this script, I took my idea from this excellent post : Ops Mgr R2 and multiple gateway servers
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | ######################################## # Gateway Server : Primary / Failover # Autor : Christopher Keyaert # Email : christopher@vnext.be # Website : http://www.vnext.be # Date : 8 DEC 2010 # Version : 0.1 # # Inspired by : http://contoso.se/blog/?p=831 ######################################## # PARAM ######################################## #FQN NAME $RMS = "xxx.CONTOSO.COM" $Gateway = "xxx.CONTOSO.COM" $PrimaryMS = "xxx.CONTOSO.COM" $failoverMS = "xxx.CONTOSO.COM" #Waiting time $WaitingTime = 3 # Minutes ######################################## # SNAP-IN + RMS Conenction ######################################## if(-not (Get-pssnapin | Where-Object {$_.Name -eq "Microsoft.EnterpriseManagement.OperationsManager.Client"})) { Add-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client } new-managementGroupConnection -ConnectionString:$RMS Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin ; Set-Location $RMS -ErrorVariable errSnapin ; ######################################## # SCRIPT ######################################## Write-Host "#######################" Write-Host "# Gateway Failover #" Write-Host "#######################" Write-Host "" Write-Host "Gateway : "$Gateway Write-Host "Primary : "$PrimaryMS Write-Host "Failover : "$FailoverMS Write-Host "" #Get server details $primaryMS = Get-ManagementServer | where {$_.Name -eq $PrimaryMS} $failoverMS = Get-ManagementServer | where {$_.Name -eq $failoverMS} $gatewayMS = Get-GatewayManagementServer | where {$_.Name -eq $Gateway} #Get current primary $CurrentPrimary = $gatewayMS | Get-PrimaryManagementServer #Set Primary as failover for configuration transfert Set-ManagementServer -GatewayManagementServer: $gatewayMS -primarymanagementserver: $primaryMS -FailoverServer: $CurrentPrimary #Wait for config change For($i = $WaitingTime; $i -gt 0; $i--) { Write-Host "Waiting $i minutes for configuration changes" Start-Sleep 60 } #Set the real configuration Set-ManagementServer -GatewayManagementServer: $gatewayMS -primarymanagementserver: $primaryMS -FailoverServer: $failoverMS #You can also run the following command shell commands to see he primary and failover server for a gateway server $CheckPrimary = Get-GatewayManagementServer | where {$_.Name -like $Gateway} | Get-PrimaryManagementServer If($CheckPrimary.Name -eq $PrimaryMS.Name) {Write-Host "Primary server OK : "$PrimaryMS.name} else{Write-Host "Primary server Failed : "$CheckPrimary.Name} $CheckFailover = Get-GatewayManagementServer | where {$_.Name -like $Gateway} | Get-FailoverManagementServer If($CheckFailover.Name -eq $failoverMS.name) {Write-Host "FailOver server OK : "$failoverMS.Name} else{Write-Host "FailOver server Failed : "$CheckFailover.Name} Write-Host "" Write-Host "END." |
failover · gateway · gw · operations manager · opsmgr · PowerShell · Scom
