Created
July 3, 2019 23:05
-
-
Save sjnovick/5656d6163d5a75be25ad248665180ae7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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