Search code examples
iisamazon-ec2windows-server

How to stop IIS on multiple AWS windows servers for maintenance purpose


I have multiple AWS EC2 windows servers. For maintenance purpose, every week we have to manually RDP and stop IIS on all the servers. This is quite cumbersome. I am looking for a way to stop all the servers in one go. Any help is appreciated.


Solution

  • To stop IIS on multiple AWS Windows servers at the same time, you can use the AWS Systems Manager Run Command feature.

    1. Open the AWS Management Console and go to the AWS Systems Manager service.

    2. In the left navigation pane, choose "Run Command".

    3. Click on "Run a command".

    4. In the "Command document" section, select "AWS-RunPowerShellScript"

    5. In the "Targets" section, select "Choose instances manually" and select the instances where you want to stop IIS.

    6. In the "Commands" section, enter the command to stop IIS. For Windows servers, you can use the following PowerShell command:

      Stop-Service -Name W3SVC

    7. Click on "Run" to execute the command on the selected instances. The command will be executed on all the selected instances simultaneously, stopping the IIS service.