Skip to content

Checking services with Powershell

09/03/2010

I use this script to check the Oracle services on the list of servers contained in servers.txt. The results are output to ServiceResults.html file.

Listing for checkServices.ps1

process{
$servername = $_
$serviceArray = Get-WmiObject -class Win32_Service -computerName $servername
$temp = @()

$serviceArray foreach {
$serviceinfo = “” select servername, name, startmode, state, status
if (($_.name -like “*Oracle*”)) {
$serviceinfo.servername = $servername
$serviceinfo.name = $_.name
$serviceinfo.startmode = $_.startmode
$serviceinfo.state = $_.state
$serviceinfo.status = $_.status
$temp +=$serviceinfo
}
}
$temp
}

I call this script file by the following:
Get-Content C:\PowershellScripts\servers.txt C:\PowershellScripts\checkServices.ps1 convertTo-Html out-file C:\PowershellScripts\ServiceResults.html

Advertisements

From → Powershell

Leave a Comment

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

%d bloggers like this: