Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views : Ad Clicks : Ad Views :
TheServerGeeks

IT with everything IT

Working with ServerComponentState

/

Microsoft Introduced ServerComponentState from Exchange Server 2013 which is also available in Exchange Server 2016 and the newest version of it 2019.

Server Component State provides granular control over the state of the components that make up an Exchange Server from the point of view of the environment it is running in. This is useful when performing database maintenance, updating CU’s where in the server will be out of operation but you still need the services running.

We have 3 Possible states for Server Component State.
                     1. Active
                     2. Inactive
                     3. Draining

Active and Inactive states are applicable for all components but Draining is applicable for only Frontend Transport and Hub Transport components, when significant component is being set to inactive,  on the other hand messages in the current queue needs to be processed.

Whenever the state of the component needs to be changed, it can be done by the ‘Requester’. We have 5 requesters available.

                     1. HealthAPI
                     2. Maintenance
                     3. Sidelined
                     4. Functional
                     5. Deployment

Let’s Assume, one of the server components is set to Inactive and the respective service is not functioning. To check the current status of the Server Component, Run the Below cmdlet to list all the server components status

Get-ServerComponentState -Identity <ServerName>
If you don’t know the current server name or the server name is hard to remember,  let PowerShell figure out the Server name and insert it for by running below cmdlet

Get-ServerComponentState -Identity $env:Computername
This will get the current logged on server name where the PowerShell cmdlet is running and insert it in the identity. 

Assume that ‘ECPproxy‘ is inactive. So, we know that only one component is inactive and we want to filter out all the other components which are given in the above cmdlet. In this case, run the below cmdlet

Get-ServerComponentState -Identity $env:Computername | where Component -like ‘ECPproxy’

Now, Lets use this Component along with the Requester to change the state to Active.

Set-ServerComponentState -Identity $env:Computername -Component ECPproxy -State Active -Requester HealthAPI

I know, being in IT field you will have to manage multiple servers in your environment as i do. In some cases, i will have to search on all the exchange servers for these components and see one by one which server has the component state set to Inactive  and causing the issue. 

If I use the first method on each server by logging in to each one of them, it’s gonna take the whole day. Well, you may think that running the second method by tweaking the cmdlet a little might work well. But, Let me tell you what is the best way to get the report from all the servers

That is, Query all the servers for only Inactive Server Components only from the same logged on the server (Assuming that all your exchange servers are in the same Domain and you have logged in with the user account which has all the required permissions on the server and Exchange service). Then, Run the below cmdlet

Get-ExchangeServer | Get-ServerComponentState | Where State -Eq ‘Inactive’

This cmdlet lists all the Inactive Components from all the Exchange servers in your domain environment.

Now, We have all the Inactive Components list in our PowerShell Console. Lets set them active so that the relative services start functioning back.

(Get-ExchangeServer | Get-ServerComponentState | Where State -Eq ‘Inactive’).Component | Set-ServerComponentSate -Component $_ -State Active -Requester HealthAPI

Above cmdlet spins through all the exchange servers, finds the Inactive Components and set them to Active state. Isn’t it amazing? 

Now, Let’s take all these cmdlet’s and create a proper script so that anyone in your organization with a delegated access can run it and bring the server components to active state

[cmdletbinding]
function Start-ServerComponents{
param(
[string]$ComputerName= $null
)
If($ComputerName -eq $null){
(Get-ExchangeServer | Get-ServerComponentState -Identity $ComputerName |
Where-Object {$_.state -eq 'inactive'}).Component |
Set-ServerComponentState -Component $_ -Identity $ComputerName -State Active -Requester HealthAPI
}
Else{
(Get-ServerComponentState -Identity $ComputerName |
Where-Object {$_.state -eq 'inactive'}).Component |
Set-ServerComponentState -Component $_ -Identity $ComputerName -State Active -Requester HealthAPI
}
}

Copy the above script and save it as .Ps1 file. 

Note: If you enter the value for -ComputerName switch, then this will execute only for that particular server. for example

Start-ServerComponents -ComputerName Server02
Start-ServerComponents -ComputerName $env:Computername


If you Just run Start-ServerComponents, then it will query all the exchange servers for inactive components and bring them active.

2 Comments

  1. Keep up the wonderful piece of work, I read few content on this web site and I conceive that your site is real interesting and has got sets of fantastic information.

  2. An intrіguing dіscussion is definitely worth comment.
    I believe that you should write more on this subject matter, it may
    not be a taboо subject bսt generally people don’t speak
    about these issues. To the next! Many thanks!!

Leave a Comment

Your email address will not be published. Required fields are marked *

This div height required for enabling the sticky sidebar