?
Solved

PowerShell Script to stop and disable services

Posted on 2016-09-09
1
Medium Priority
?
132 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 2000 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

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

Question has a verified solution.

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

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Loops Section Overview
Screencast - Getting to Know the Pipeline
Suggested Courses

589 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