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"

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.