Solved

PowerShell Script to stop and disable services

Posted on 2016-09-09
1
54 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
A brief introduction to what I consider to be the best editor for PowerShell.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now