Skip to content

Checking services with Powershell


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

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

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

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


From → Powershell

Leave a Comment

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

%d bloggers like this: