Thursday, 19 March 2015

One-to-Many Remote Management in Exchange Server 2010

Exchange Server 2010 provides one of the cool features of managing Exchange Server 2010 in our network from remote locations by using PowerShell. Â Remote Management in Exchange Server 2010 allow administrators to establish remote sessions with multiple Exchange Servers and invoke remote commands on multiple Exchange computers. When we remotely invoke commands, PowerShell runs the commands on the remote computers and return al output from the commands. This remote connection will only be established as long as is required to return the output. Any command entered in the PowerShell is executed on all computers to which you are connected whether this is 1 computer or 100 computers.  

One important thing to note down is that WinRM must be appropriately configured on computers that you want to remotely manage. WinRM listeners are not created by default. We can create the require listeners by running winrm quickconfig command.
The following command entered as a single line invokes the Get-Service and Get- Process commands on the servers: 
invoke-command -computername ExchServer10, ExchServer20, ExchServer30 -scriptblock {get-service; get-process}
 
Below command establishes a remote session with the specified mail servers: 
$s = new-PSSession -computername ExchServer10, ExchServer20, ExchServer30 -Credential Techpeoples\SachinM
 
After you establish the session, you can then use the $s session with Invoke-Command to return commands on all remote computers you are connected to.
In this example, you look for stopped Exchange services on each computer: 
invoke-command -session $s -scriptblock {get-service mse* | where { $_.status -eq "stopped"}} 

In this example, you pipe the output of Get-Service to the Where-Object cmdlet and filter based on the Status property.As the $_ automatic variable operates on the current object in the pipeline, PowerShell examines the status of each service in turn and lists only those that are stopped in the output. 

No comments:

Post a Comment