Stop and disable a Windows service using powershell: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
} | } | ||
</pre> | </pre> | ||
[[Category:PowerShell]] |
Revision as of 10:33, 10 August 2021
Create a file called computers.txt and populate it as below:
server01 server02 server03
Change the service name below to match what it is you want to stop and disable, save this script in the same location as computers.txt:
$SrvNames = Get-Content -Path 'C:\data\scripts\computers.txt' foreach ($Server in $SrvNames) { Get-Service -Name "Rubrik Backup Service" -ComputerName $Server | Stop-Service -PassThru | Set-Service -StartupType disabled }