I have a routine that starts a service on a remote server:
Invoke-command -Session $ession -ScriptBlock { Start-Service -InputObject $args[0] } -ArgumentList $svc.Name
The routine works fine.
I wanted to explore redirecting the messages that I see in the OUTPUT tab/console to a text box to give the user additional feedback.
This is an example of what I see:
WARNING: Waiting for service 'DataCaptor Interface Server (DataCaptor Interface Server)' to start...
I have tried assigning the Invoke-command to a variable but that did not seem to help.
Can someone point me in the right direction?
Thank you in advance.
Redirecting Start-Service output from a remote session
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Redirecting Start-Service output from a remote session
No need to use Invoke-Command to start a remote service:
Get-Service $svc.Name -ComputerName <comouter> | Start-Service
To learn about redirecting review the following:
help redirection
Get-Service $svc.Name -ComputerName <comouter> | Start-Service
To learn about redirecting review the following:
help redirection