DevSupport
asked on
Getting get-service results from remote system into script variables
I am trying to get the results from a command Get-Service remotely and get the "status" result into a text box.
When I do Get-Service -DisplayName "windows audio" locally
I get
Status Name DisplayName
------ ---- -----------
Running AudioSrv Windows Audio
I would like to run it remotely using invoke-command and obtain the "Running" into an array or something, so that I can show in text box.
When I try the below I get $AppState as Name or "Audiosrv", but I am unable to get the Status value into array.
$AppState = Invoke-Command -Computername $objappsvrname.Text -ArgumentList $dispname -ScriptBlock {Param($DisplayName); Get-Service -DisplayName $DisplayName}
Please let me know how I can get the status "Running" into $AppState
Please let me know if you need more info.
When I do Get-Service -DisplayName "windows audio" locally
I get
Status Name DisplayName
------ ---- -----------
Running AudioSrv Windows Audio
I would like to run it remotely using invoke-command and obtain the "Running" into an array or something, so that I can show in text box.
When I try the below I get $AppState as Name or "Audiosrv", but I am unable to get the Status value into array.
$AppState = Invoke-Command -Computername $objappsvrname.Text -ArgumentList $dispname -ScriptBlock {Param($DisplayName); Get-Service -DisplayName $DisplayName}
Please let me know how I can get the status "Running" into $AppState
Please let me know if you need more info.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER