Skip to content

Instantly share code, notes, and snippets.

@sjnovick
Created July 3, 2019 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjnovick/5656d6163d5a75be25ad248665180ae7 to your computer and use it in GitHub Desktop.
Save sjnovick/5656d6163d5a75be25ad248665180ae7 to your computer and use it in GitHub Desktop.
# parallel_stop_svc.ps1
#
# A PowerShell script to stop a windows service on many target computers in parallel
# For example: Stopping IIS service on all servers in your web farm
#
# sjnovick 2016
#
# Unloads the workflow / module "stopsvc" from the below file.
#rmo .\workflow-parallel_stop_service.ps1
# Loads the workflow / module "stopsvc" from the below file.
#ipmo .\workflow-parallel_stop_service.ps1
workflow stopsvc {
param(
[string[]]$computers,
[string[]]$services
)
foreach -parallel ($computer in $computers) {
Stop-Service -PSComputerName $computer -Name $services -InformationAction $InformationAction
}
}
# Calls the "stopsvc" workflow / module, requires at least one computer and at least one service.
# Will accept multiple computers and multiple services. Use a comma delimited list, no parantheses, quotes, etc. required.
stopsvc -computers www1.sjno.net,www2.sjno.net,www3.sjno.net,www4.sjno.net,www5.sjno.net,www6.sjno.net -services w3logsvc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment