Forum Discussion
SteveCox
Oct 11, 2021Brass Contributor
Automation of Exchange server Patching
Hi I am trying to setup a Script to automate patching of Exchange 2016 servers and I need to get the script to check if any if the other exchange server is in Maintenance Mode before continuing to pl...
Oct 11, 2021
You could do like this
$Maint = Get-DatabaseAvailabilityGroup -status
If ($Maint.ServersInMaintenance.count -eq 0 ) { Write-Host "No Servers in Maintenance Mode"}
This if you only have one DAG.
If you have more than one you will need to iterate between them
$Maint = Get-DatabaseAvailabilityGroup -status
If ($Maint.ServersInMaintenance.count -eq 0 ) { Write-Host "No Servers in Maintenance Mode"}
This if you only have one DAG.
If you have more than one you will need to iterate between them
- SteveCoxOct 11, 2021Brass ContributorThanks that works perfectly now need to check cluster node Status so if I run
"Get-ClusterNode -Name Exchange1 | FL State"
I Get "State : Up" as an output but if I try
"$cluster = Get-ClusterNode -Name Exchange1 | FL State
If ($cluster.state -eq "Up") { Write-Host "Cluster is Up"}
I get nothing- Oct 11, 2021Have to boot up my Exchange lab to check, however, be careful while assigning Format-List output to a variable, that should be used only to output to screen.
So it would be better to:
$cluster = Get-ClusterNode -Name Exchange1
If ($cluster.state -eq "Up") { Write-Host "Cluster is Up"}- SteveCoxOct 12, 2021Brass ContributorThanks yes this work thanks for the pointer on the Format-List assignment, Once I have a working version of this completed I will post it here