signalhouse
signalhouse

Reputation: 83

Display only the status from Invoke-Command

I need to display only the status from the below command.

Invoke-Command -ComputerName "infidltetl" -ScriptBlock {Get-Service -Name "Informatica 10.2.2" | Select-Object -Property Status}

Current output:

Status  PSComputerName RunspaceId                          
------  -------------- ----------                          
Running infidltetl     e3878de0-d931-480b-b637-b8957301c933

I want to print only the value under the status property (Running/Not started etc.) But from the above command, it prints other values which I don't want.

Thanks.

Upvotes: 1

Views: 361

Answers (1)

Mark Harwood
Mark Harwood

Reputation: 2415

Using this works for me:

Invoke-Command -ComputerName HOST_NAME -ScriptBlock {
    Get-Service -Name SERVICE_NAME
} | Select-Object -ExpandProperty Status

Upvotes: 1

Related Questions