This tutorial is about PowerShell and running script to disable some Services in Windows.
The Windows PowerShell execution policy allows your scripts to run on your computer.
If you want to see the Windows PowerShell execution policy, use the Get-ExecutionPolicy command.
To change the Windows PowerShell execution policy on your computer, use the Set-ExecutionPolicy command.
You can see all of the execution policies that affect the current session by using the Get-ExecutionPolicy -List command.
To run my script needs to have a command shell administrator rights and select a policy that allows running the script ( example: Unrestricted).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #Requires -Version 3.0 <# Requires -RunAsAdministrator "-file fullpathofthescript" #> <# .DESCRIPTION Script to disable services in Windows OS Requires Admin Access Twitter: @catafest .NOTES File Name : stop-net-services.ps1 Author : @catafest .LINK http://free-tutorials.org #> $services = @( # Services by capabilities "DcpSvc" # Data Collection and Publishing Service "NetTcpPortSharing" # Net.Tcp Port Sharing Service "RemoteAccess" # Routing and Remote Access "RemoteRegistry" # Remote Registry "WbioSrvc" # Windows Biometric Service "WMPNetworkSvc" # Windows Media Player Network Sharing Service "WSearch" # Windows Search # Games Based "XblAuthManager" # Xbox Live Auth Manager "XblGameSave" # Xbox Live Game Save Service "XboxNetApiSvc" # Xbox Live Networking Service # HomeGroup "HomeGroupListener" # HomeGroup Listener "HomeGroupProvider" # HomeGroup Provider # other "OneSyncSvc" # Sync Host Service "AeLookupSvc" # Application Experience Service "PcaSvc" # Program Compatibility Assistant "ERSVC" # Error Reporting Service "WERSVC" # Windows Error Reporting Service "SSDPSRV" # SSDP Discovery Service "CDPSvc" # Connected Devices Platform Service "DsSvc" # Data Sharing Service "DcpSvc" # Data Collection and Publishing Service "lfsvc" # Geolocation service ) foreach ($service in $services) { if ( Get-Service "$service*" -Include $service ) { Write-Host " Disabling Service $service ..." Get-Service -Name $service | Stop-Service -Force Get-Service -Name $service | Set-Service -StartupType Disabled } } |
After running the script the output is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 | .\net_disable_services.ps1 Disabling Service NetTcpPortSharing ... Disabling Service RemoteAccess ... Disabling Service RemoteRegistry ... Disabling Service WbioSrvc ... Disabling Service WMPNetworkSvc ... Disabling Service WSearch ... Disabling Service HomeGroupListener ... Disabling Service HomeGroupProvider ... Disabling Service AeLookupSvc ... Disabling Service PcaSvc ... Disabling Service WERSVC ... Disabling Service SSDPSRV ... |