Hey Everyone
I'm one of the newbies here and I am trying to disable several services on several servers remotely.
I found a post by Martin but I wanted to post here so that I can use 1 forum.
Here was the answer Martin suggested and it worked for the user, but I can't get it to work. There are a couple of services that have a !Space! in the name, but I tried with services that do not. I also want to stop the service and disable it. This doesn't do that. Can anyone help?
1. Create a CSV like this
ComputerName,Service Server1,"service1,service2,service3" server2,"service4,service5,service6"
2. Use this code:
$List=Import-CSVc:\scripts\servers.csvForEach($Serverin$List){Invoke-Command-ScriptBlock{Stop-Service$args[0]}-ComputerName$Server.ComputerName-ArgumentList$Server.Service.Split(",")}Start-Sleep-Seconds60ForEach($Indexin(($List.Count-1)..0)){Invoke-Command-ScriptBlock{Stop-Service$args[0]}-ComputerName$List[$Index].ComputerName-ArgumentList$List[$Index].Service.Split(",")