Skip to content

Commit c3a3867

Browse files
authored
Update service disabler.ps1
1 parent 5b71d4e commit c3a3867

File tree

1 file changed

+10
-81
lines changed

1 file changed

+10
-81
lines changed

Individual Scripts/service disabler.ps1

+10-81
Original file line numberDiff line numberDiff line change
@@ -91,85 +91,14 @@ $services = @(
9191
)
9292

9393
foreach ($service in $services) {
94-
Write-Output "Trying to disable $service"
95-
Get-Service -Name $service | Set-Service -StartupType Disabled
96-
}
94+
# -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
95+
96+
Write-Host "Setting $service StartupType to disabled"
97+
Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled
9798

98-
#check if services are running and if they are then stop them
99-
Get-Service diagnosticshub.standardcollector.service | Where {$_.status –eq 'running'} | Stop-Service
100-
Get-Service DiagTrack | Where {$_.status –eq 'running'} | Stop-Service
101-
Get-Service dmwappushservice | Where {$_.status –eq 'running'} | Stop-Service
102-
Get-Service lfsvc | Where {$_.status –eq 'Stopped'} | Stop-Service
103-
Get-Service MapsBroker | Where {$_.status –eq 'running'} | Stop-Service
104-
Get-Service NetTcpPortSharing | Where {$_.status –eq 'running'} | Stop-Service
105-
Get-Service RemoteAccess | Where {$_.status –eq 'running'} | Stop-Service
106-
Get-Service RemoteRegistry | Where {$_.status –eq 'running'} | Stop-Service
107-
Get-Service TrkWk | Where {$_.status –eq 'running'} | Stop-Service
108-
Get-Service WbioSrvc | Where {$_.status –eq 'running'} | Stop-Service
109-
#Get-Service WlanSvc | Where {$_.status –eq 'running'} | Stop-Service
110-
Get-Service WMPNetworkSvc | Where {$_.status –eq 'running'} | Stop-Service
111-
#Get-Service wscsvc | Where {$_.status –eq 'running'} | Stop-Service
112-
Get-Service WSearch | Where {$_.status –eq 'running'} | Stop-Service
113-
Get-Service XblAuthManager | Where {$_.status –eq 'running'} | Stop-Service
114-
Get-Service XblGameSave | Where {$_.status –eq 'running'} | Stop-Service
115-
Get-Service XboxNetApiSvc | Where {$_.status –eq 'running'} | Stop-Service
116-
Get-Service XboxGipSvc | Where {$_.status –eq 'running'} | Stop-Service
117-
Get-Service ndu | Where {$_.status –eq 'running'} | Stop-Service
118-
Get-Service WerSvc | Where {$_.status –eq 'running'} | Stop-Service
119-
Get-Service Spooler | Where {$_.status –eq 'running'} | Stop-Service
120-
Get-Service Fax | Where {$_.status –eq 'running'} | Stop-Service
121-
Get-Service fhsvc | Where {$_.status –eq 'running'} | Stop-Service
122-
Get-Service gupdate | Where {$_.status –eq 'running'} | Stop-Service
123-
Get-Service gupdatem | Where {$_.status –eq 'running'} | Stop-Service
124-
Get-Service stisvc | Where {$_.status –eq 'running'} | Stop-Service
125-
Get-Service AJRouter | Where {$_.status –eq 'running'} | Stop-Service
126-
Get-Service MSDTC | Where {$_.status –eq 'running'} | Stop-Service
127-
Get-Service WpcMonSvc | Where {$_.status –eq 'running'} | Stop-Service
128-
Get-Service PhoneSvc | Where {$_.status –eq 'running'} | Stop-Service
129-
Get-Service PrintNotify | Where {$_.status –eq 'running'} | Stop-Service
130-
Get-Service PcaSvc | Where {$_.status –eq 'running'} | Stop-Service
131-
Get-Service WPDBusEnum | Where {$_.status –eq 'running'} | Stop-Service
132-
#Get-Service LicenseManager | Where {$_.status –eq 'running'} | Stop-Service
133-
Get-Service seclogon | Where {$_.status –eq 'running'} | Stop-Service
134-
Get-Service SysMain | Where {$_.status –eq 'running'} | Stop-Service
135-
Get-Service lmhosts | Where {$_.status –eq 'running'} | Stop-Service
136-
Get-Service wisvc | Where {$_.status –eq 'running'} | Stop-Service
137-
Get-Service FontCache | Where {$_.status –eq 'running'} | Stop-Service
138-
Get-Service RetailDemo | Where {$_.status –eq 'running'} | Stop-Service
139-
Get-Service ALG | Where {$_.status –eq 'running'} | Stop-Service
140-
#Get-Service BFE | Where {$_.status –eq 'running'} | Stop-Service
141-
Get-Service BrokerInfrastructure | Where {$_.status –eq 'running'} | Stop-Service
142-
Get-Service SCardSvr | Where {$_.status –eq 'running'} | Stop-Service
143-
Get-Service EntAppSvc | Where {$_.status –eq 'running'} | Stop-Service
144-
Get-Service BthAvctpSvc | Where {$_.status –eq 'running'} | Stop-Service
145-
Get-Service BDESVC | Where {$_.status –eq 'running'} | Stop-Service
146-
Get-Service iphlpsvc | Where {$_.status –eq 'running'} | Stop-Service
147-
Get-Service edgeupdate | Where {$_.status –eq 'running'} | Stop-Service
148-
Get-Service MicrosoftEdgeElevationService | Where {$_.status –eq 'running'} | Stop-Service
149-
Get-Service edgeupdatem | Where {$_.status –eq 'running'} | Stop-Service
150-
Get-Service SEMgrSvc | Where {$_.status –eq 'running'} | Stop-Service
151-
#Get-Service PNRPsvc | Where {$_.status –eq 'running'} | Stop-Service
152-
#Get-Service p2psvc | Where {$_.status –eq 'running'} | Stop-Service
153-
Get-Service p2pimsvc | Where {$_.status –eq 'running'} | Stop-Service
154-
Get-Service PerfHost | Where {$_.status –eq 'running'} | Stop-Service
155-
Get-Service BcastDVRUserService_48486de | Where {$_.status –eq 'running'} | Stop-Service
156-
Get-Service CaptureService_48486de | Where {$_.status –eq 'running'} | Stop-Service
157-
Get-Service cbdhsvc_48486de | Where {$_.status –eq 'running'} | Stop-Service
158-
Get-Service BluetoothUserService_48486de | Where {$_.status –eq 'running'} | Stop-Service
159-
Get-Service WpnService | Where {$_.status –eq 'running'} | Stop-Service
160-
Get-Service StorSvc | Where {$_.status –eq 'running'} | Stop-Service
161-
Get-Service QWAVE | Where {$_.status –eq 'running'} | Stop-Service
162-
Get-Service RtkBtManServ | Where {$_.status –eq 'running'} | Stop-Service
163-
Get-Service HPAppHelperCap | Where {$_.status –eq 'running'} | Stop-Service
164-
Get-Service HPDiagsCap | Where {$_.status –eq 'running'} | Stop-Service
165-
Get-Service HPNetworkCap | Where {$_.status –eq 'running'} | Stop-Service
166-
Get-Service HPSysInfoCap | Where {$_.status –eq 'running'} | Stop-Service
167-
Get-Service HpTouchpointAnalyticsService | Where {$_.status –eq 'running'} | Stop-Service
168-
Get-Service HvHost | Where {$_.status –eq 'running'} | Stop-Service
169-
Get-Service vmickvpexchange | Where {$_.status –eq 'running'} | Stop-Service
170-
Get-Service vmicguestinterface | Where {$_.status –eq 'running'} | Stop-Service
171-
Get-Service vmicshutdown | Where {$_.status –eq 'running'} | Stop-Service
172-
Get-Service vmicheartbeat | Where {$_.status –eq 'running'} | Stop-Service
173-
Get-Service vmicvmsession | Where {$_.status –eq 'running'} | Stop-Service
174-
Get-Service vmicrdv | Where {$_.status –eq 'running'} | Stop-Service
175-
Get-Service vmictimesync | Where {$_.status –eq 'running'} | Stop-Service
99+
$running = Get-Service -Name $service -ErrorAction SilentlyContinue | Where-Object {$_.Status -eq 'Running'}
100+
if ($running) {
101+
Write-Host "Stopping $service"
102+
Stop-Service -Name $service
103+
}
104+
}

0 commit comments

Comments
 (0)