Check Service Status Parallelly across multiple servers using PowerShell


Hi All,

If you want to check the services across multiple remote servers , below script will be useful. It uses PowerShell work flow and works in multi-threaded way.

workflow parallelServiceCheck {

param(

[String[]]$ComputerName,

[string]$Status,

[String]$serviceName

)

$obj =New-Object –TypeName PSObject

$Services=$null

if (!([String]::IsNullOrEmpty($serviceName)))

{

$Services = Get-Service -Name $($serviceName) | where { $_.Status -eq $Status }

}

else

{

$Services = Get-Service| where { $_.Status -eq $Status }

}

Add-Member -InputObject $obj -MemberType NoteProperty -Name Services -Value $Services -Force

$obj| select servername, services|select -ExpandProperty services|select Name,Status

}

Clear-Host

parallelServiceCheck -PSComputerName Server1,Server2 `

-Status ‘running’ ` # status is mandatory

-Servicename ” `

|select PSComputerName,Name,Status | Out-GridView

Regards,

Chaitanya

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 )

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 )

w

Connecting to %s

%d bloggers like this: