Why the Queue is not available after running Set-ServerComponentState

%3CLINGO-SUB%20id%3D%22lingo-sub-2037876%22%20slang%3D%22en-US%22%3EWhy%20the%20Queue%20is%20not%20available%20after%20running%20Set-ServerComponentState%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2037876%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20all%3C%2FP%3E%3CP%3EI%20am%20doing%20a%20script%20to%20automate%20some%20steps%20related%20to%20server%20maintenance%2C%20but%20there%20is%20a%20strange%20behavior%20from%20Exchange%2C%20The%20Queue%20is%20not%20available%20for%20sometime%20after%20Running%26nbsp%3BSet-ServerComponentState%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3ESet-ServerComponentState%20-Identity%20ex01%20-Component%20HubTransport%20-State%20Draining%20-Requester%20Maintenance%20%0Awhile%20(%24true)%7B%0AGet-ServerComponentState%20-Identity%20ex01%20-Component%20HubTransport%0A(Test-ServiceHealth).ServicesNotRunning%0AGet-Queue%20-Server%20ex01%20%7C%20select%20MessageCount%0Aif%20((get-service%20MSExchangeFrontEndTransport).Status%20-notlike%20%22Running%22)%7BWrite-Host%20get-service%20MSExchangeFrontEndTransport%20-ForegroundColor%20Red%7D%0Asleep%20-Seconds%202%0A%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELevae%20this%20script%20running%20for%20about%2030%20second%20and%20then%20you%20will%20get%20an%20error%20that%26nbsp%3B%3C%2FP%3E%3CP%3EGet-Queue%20%3A%20Exchange%20can't%20connect%20to%20the%20Microsoft%20Exchange%20Transport%20service%20on%20computer%20%22ex01%22.%20Verify%20that%20the%20service%3CBR%20%2F%3Eis%20started.%3CBR%20%2F%3EAt%20line%3A5%20char%3A1%3CBR%20%2F%3E%2B%20Get-Queue%20-Server%20ex01%20%7C%20select%20MessageCount%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20InvalidOperation%3A%20(%3A)%20%5BGet-Queue%5D%2C%20LocalizedException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20%5BServer%3DEX01%2CRequestId%3Dccb3aa23-4dfc-45f3-9b87-82de2536a9b3%2CTimeStamp%3D1%2F7%2F2021%204%3A52%3A45%20AM%5D%20%5BF%3CBR%20%2F%3EailureCategory%3DCmdlet-LocalizedException%5D%20A97D44C4%2CMicrosoft.Exchange.Management.QueueViewerTasks.GetQueueInfo%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20Windows%20Event%20log%20I%20notice%20that%20there%20is%20a%20failure%20related%26nbsp%3B%3CSTRONG%3EMSExchangeFrontEndTransport%3C%2FSTRONG%3E%2C%20even%20though%20the%20service%20is%20not%20restarting%2C%20but%20it%20seems%20its%20a%20configuration%20reload.%3C%2FP%3E%3CP%3ECan%20someone%20confirm%20what%20is%20going%20on.%20is%20it%20a%20config%20reload%20or%20why%20the%20Queue%20becomes%20unavailable%20for%20sometime%26nbsp%3B%20after%20set-ServerComponenetState.%3C%2FP%3E%3CP%3EI%20tried%20this%20on%20both%20Exchange%202016%20and%20Exchange%202019%2C%20same%20result%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2037876%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E2016%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2299746%22%20slang%3D%22en-US%22%3ERe%3A%20Why%20the%20Queue%20is%20not%20available%20after%20running%20Set-ServerComponentState%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2299746%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F790105%22%20target%3D%22_blank%22%3E%40farismalaeb%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20restart%20of%20the%20MSExcahngeTransport%20and%20MSExchangeFrontEndTransport%20services%20in%20my%20script%20directly%20after%20the%20Set-ServerComponentState%20to%20speed%20up%20the%20draining%20process%20in%20out%20automation%20script%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3ESet-ServerComponentState%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3Escript%3C%2FSPAN%3E%3CSPAN%3E%3Aserver%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-Component%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BHubTransport%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-State%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BDraining%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-Requester%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3BMaintenance%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EGet-Service%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22MSExchangeTransport%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-ComputerName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3Escript%3C%2FSPAN%3E%3CSPAN%3E%3Aserver%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERestart-Service%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-PassThru%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EGet-Service%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%22MSExchangeFrontEndTransport%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-ComputerName%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%24%3C%2FSPAN%3E%3CSPAN%3Escript%3C%2FSPAN%3E%3CSPAN%3E%3Aserver%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%7C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERestart-Service%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E-PassThru%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ethen%20it%20goes%20on%20to%20Redirect-Message%20...%20this%20may%20help%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Super 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.