• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

TECHDIIP

  • Tech
  • Windows
  • Powershell
  • Scripts
  • News
  • Games

Powershell Stop Service on Remote Computers

This article explains how to Stop a Service on any windows computer remotely using Powershell script, one can also use the same script stop the service on multiple remote computers.

When you want to stop service on a desktop computer or a server we generally open the services and find the name of service and we stop if you want to do the same more on remote computers it is difficult to log in to each server and stop the service, here in this article I will explain how to stop a service remotely using the PowerShell command.

Powershell Stop-Service

This PowerShell command stops specified service, either you can provide service name or display name of the service.

Let’s stop service and see how it works, the name of the service Adobe Acrobat Update Service its current status is running.

Stop-Service -Name AdobeARMservice -force

Let’s get the status of this service.

PS C:\Windows\system32> get-Service -Name AdobeARMservice

Status   Name               DisplayName
------   ----               -----------
Stopped  AdobeARMservice    Adobe Acrobat Update Service

See the Service is stopped.

 Stop a Service on Remote Computers

We need to create a file for storing all the servers or multiple machines lists, I named itas Allserver.txt for and saved it in my local machine c:\temp\Allserver.txt

#remote machines list

$Allserver = Get-Content -Path "C:\temp\AllServer.txt"

foreach ($server in $allserver)
  {

Write-Host "Currently the script is restarting the serivce on" $server

Invoke-Command -ComputerName $server -ScriptBlock {stop-Service -name AdobeARMservice}

}

Parameters of Restart-Service

-Force

This parameter forces the command to restart a service without asking the user confirmation.

stop-Service -Name wuauserv -force

-Name

This parameter is used for specifying the name fo the service that you want to stop.

-Confirm

This parameter prompts user confirmation before it stops the service.

stop-Service -Name wuauserv -Confirm

-DisplayName

This parameter used for specifying the display name of the service that you need to stop.

stop-Service -DisplayName Windows Update

–Exclude

This parameter excludes the services that are not required to stop, wildcard characters are permitted.

stop-Service -DisplayName “win” -Exclude “net logon”

-Include

stop-Service -DisplayName “win” -Include “net logon”

-PassThru

This parameter returns an object that represents the service.

-WhatIf

This parameter shows what happens when you execute a command, I strongly recommend testing this before you start multiple services at once.

Thank you for reading this article, if you have any questions please let us know.

Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.

 

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • How do Zoom Application Testing | Working or Not
  • Powershell script to test website status up or down on a local or remote computers
  • Solved: Server execution failed windows 10 Server 2016 and 2019
  • How to Fix windows 10 version 1903 error 0xc1900223
  • Free Music Making Software List One Can Try Out
  • About Us
  • CONTACT US
  • Disclaimer
  • Privacy Policy

Copyright © 2023 techdiip.com