Trying to make a script that disables a service at all network computers

I think this would work for you. You would need to create a text file with a list of computers. Replace the path where it says c:\_Test and enter the name of the service when it asks you. This will also check to make sure both the service was stopped and disabled.

$comps = Get-Content -Path c:\_Test\computers.txt

$servicename = Read-Host 'Enter name of Service'

$service = Get-Service -Name $servicename

foreach($comp in $comps){

if($service.status -eq 'Running'){

Get-Service -Name $service | Stop-Service -Force

Set-Service -Name $service -StartupType Disabled

if($service.status -eq 'Stopped' -and $service.StartType -like 'Disabled'){

Write-Host "Successfully stopped and disabled" $service "on" $comp

}

else{

Write-Host "$comp failed to stop and disable service"

}

}

}

/r/PowerShell Thread