Hi guys, once again I'm begging for pardon if this is a dumb question.
I have some trouble pipeline the command as I want to.
Let's imagine I have two different computers in the same network (computer A and computer B) and what I'am trying to accomplish is to remotley start a process and set it in startup type "automatic".
Here's what I'm trying to do:
Let's say the service "Print Spooler" has stopped working on computer B and it won't restart itself as it should, so I have to give it a little nudge.
So I begin by remotley kill it's process (spoolsv.exe) from computer A. Then I just want to restart the service at computer B, by running the following command:
Start-Service -InputObject (Get-Service -ComputerName "computer B" -Name "Spooler")
At this point the service "Spooler" or "Print Spooler" start's up just as it should..BUT I'm also want to pipe the command above with "Set-Service" so I could be sure the service get the correct startup type, in case the computer/server has to reboot.
So what I'm trying to do is this:
Start-Service -InputObject (Get-Service -ComputerName "computer B" -Name "Spooler") | Set-Service -ComputerName "Computer B" -Name "Spooler" -StartupType "Automatic"
The shell accept my command and don't return any errors, but the service "Print Spooler"/"Spooler" don't receive the startup type "automatic" at Computer B.
But if I choose to run the commands separated from each other, let's say I first run the command: "Start-Service -InputObject (Get-Service -ComputerName "computer B" -Name "Spooler")"and then hit return and then type in "Set-Service -ComputerName "Computer B" -Name "Spooler" -StartupType "Automatic""it work perfectly fine.
That's why I'm think there's a problem with how I have chosen to pipe my command.