This script is needed when the server is out of maintenance mode but the component state is still INACTIVE. I've tested this on Exchange 2016 and Windows Server 2012 R2. Script canb eused for both DAG and non DAG Servers.

Follow the Blog post here -

Written by Adnan Rafique @ExchangeITPro
V1.1 08.06.2014
Bring server componet to active state.
Bring component state to active state.
Specifies the DAG node Server name to be bring the component to active state. 
PS> .\SetExchangeComponentToActive.ps1 -Server Server1

#Requires -version 3.0

    [Parameter(Mandatory = $true,
    HelpMessage="Enter the name of Server to set component to active.")]

#Designates that the server is out of maintenance mode and set the component to Active state
Set-ServerComponentState $Server -Component ServerWideOffline -State Active -Requester Functional
Set-ServerComponentState $Server -Component Monitoring -State Active -Requester Functional
Set-ServerComponentState $Server -Component RecoveryActionsEnabled -State Active -Requester Functional

#Get the status of component
Get-ServerComponentState $Server | ft Component,State -Autosize
Write-Host "$Server is now completely out of maintenance mode and component are active and functional." -ForegroundColor Yellow