Stop and disable a Windows service using powershell: Difference between revisions

From roonics
Jump to navigation Jump to search
(Created page with "stuff")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
stuff
Create a file called computers.txt and populate it as below:
 
<pre>
server01
server02
server03
</pre>
 
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:
 
<pre>
$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
}
</pre>
 
[[Category:PowerShell]]
‎<comments />

Latest revision as of 09:07, 20 March 2022

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
}

‎<comments />