Hey all,
I am trying to figure out how to start services remotely via a PS script. I have a good 40ish computers that need a service started, and I don't wanna go to each one individually. I have used ForEach scripts in the past for certian PS functions, but this is my first time messing with services, and apparantly you can't use -tosession as part of the command.
My origional script looks like this:
$computers = get-content C:\Users\user\Desktop\computers.csv
ForEach ($computer in $computers) {
$session = New-PSSession -ComputerName $computer
Set-Service -name service -StartupType Automatic -ToSession $session
}
However, I'm getting this error:
"Set-Service : A parameter cannot be found that matches parameter name 'ToSession'."
I was thinking of piping the commands via an enter-pssession, but my last attempt at that was bad and looked like this:
enter-pssession -computername $computer | set-service -name service -startuptype automatic
Any and all help would be appreciated.