Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PowerShell Script to stop and disable services

Posted on 2016-09-09
1
63 Views
Last Modified: 2016-09-18
Does anyone have a PowerShell script to stop and disable services on a specific server?
0
Comment
Question by:amazon4life
1 Comment
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41791871
Try this..
Import-CSV C:\Temp\input.csv | % {
$service = Get-WmiObject win32_service -computername $_.Server -filter "name='$($_.service)'"
$service.stopservice() | Out-Null
$service.ChangeStartMode("Disabled") | Out-Null
}

Open in new window

Sample input file..
Server,service
ServerA,Spooler
ServerB,WinRM

Open in new window

1

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question