I wrote this script to restart Exchange 2010 services that sometimes fail to restart after a power outage, but it's extensible to just about any service or situation. It accepts a parameter of the computer name to connect to, but has a default value you'll want to change to match your environment.

I use a combination of PSSession and WMI to only start the services that are "Auto" and not currently running. The main reason for WMI here, instead of the PowerShell Get-Service cmdlet is that Get-Service doesn't return the StartMode parameter, and I don't want to be starting services that are set to Manual.


# Script to start Exchange services after power failure 
# Accepts a parameter of the exchange server name, but defaults to SRV2 if none entered 
# Assumes you are logged in to the domain with Domain Admin credentials 
# Created: 14/03/2011 by Charlie Russel 
# ModHist: 15/03/2011 -- switched to using WMI in a session so I could get StartMode 
param ($ExchSrv = "SRV2" ) 
$srv = New-PSSession $ExchSrv 
Invoke-Command -Session $srv -scriptblock {  
   $exsvc = gwmi win32_service | Where-Object {$_.Name -like "MsExch*"  -and $_.StartMode -eq "Auto"   -and $_.State -eq "Stopped" }  
   if ($exsvc ) {  
      foreach ($svc in $exsvc ) { 
         Start-Service $