Check and Start – Services Automatic and not running

Had some issues in a virtual environment that we often rollback and rebuild. Before deploying the build, we wanted to be sure that all automatic services in fact were running. The below scripts does just that.
Just change the server(s) located on $Servers.

This script will attempt to start all services that are automatic, some services will stop immediately after, that is normal.
#– Automatic Service started verification.

$Servers = '<Server01>','<Server02>'

Foreach ($Server in $Servers) {
	$Services= Get-WmiObject Win32_Service -ComputerName $Server | Where-Object { $_.StartMode -eq 'Auto' -and $_.State -ne 'Running' }
	Foreach ($service in $Services) {
		$service.StartService() | Out-null
		}
	}
write-host "Automatic services started"
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s