Why the Queue is not available after running Set-ServerComponentState

Steel Contributor

Hi all

I am doing a script to automate some steps related to server maintenance, but there is a strange behavior from Exchange, The Queue is not available for sometime after Running Set-ServerComponentState

 

 

Set-ServerComponentState -Identity ex01 -Component HubTransport -State Draining -Requester Maintenance 
while ($true){
Get-ServerComponentState -Identity ex01 -Component HubTransport
(Test-ServiceHealth).ServicesNotRunning
Get-Queue -Server ex01 | select MessageCount
if ((get-service MSExchangeFrontEndTransport).Status -notlike "Running"){Write-Host get-service MSExchangeFrontEndTransport -ForegroundColor Red}
sleep -Seconds 2

}

 

Levae this script running for about 30 second and then you will get an error that 

Get-Queue : Exchange can't connect to the Microsoft Exchange Transport service on computer "ex01". Verify that the service
is started.
At line:5 char:1
+ Get-Queue -Server ex01 | select MessageCount
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-Queue], LocalizedException
+ FullyQualifiedErrorId : [Server=EX01,RequestId=ccb3aa23-4dfc-45f3-9b87-82de2536a9b3,TimeStamp=1/7/2021 4:52:45 AM] [F
ailureCategory=Cmdlet-LocalizedException] A97D44C4,Microsoft.Exchange.Management.QueueViewerTasks.GetQueueInfo

 

In the Windows Event log I notice that there is a failure related MSExchangeFrontEndTransport, even though the service is not restarting, but it seems its a configuration reload.

Can someone confirm what is going on. is it a config reload or why the Queue becomes unavailable for sometime  after set-ServerComponenetState.

I tried this on both Exchange 2016 and Exchange 2019, same result

2 Replies

@farismalaeb

 

I have a restart of the MSExcahngeTransport and MSExchangeFrontEndTransport services in my script directly after the Set-ServerComponentState to speed up the draining process in out automation script

 

Set-ServerComponentState $script:server -Component HubTransport -State Draining -Requester Maintenance
Get-Service "MSExchangeTransport" -ComputerName $script:server | Restart-Service -PassThru
Get-Service "MSExchangeFrontEndTransport" -ComputerName $script:server | Restart-Service -PassThru
 
then it goes on to Redirect-Message ... this may help?

 

Thanks for your response, but instead, I used TRAP to get the error, wait until the trap is completed, then proceed with the next step.