Site icon Ryadel

Start, Stop and Restart IIS from a Remote PC

Exporting & Importing App Pools and Websites configuration between multiple IIS instances

Introduction

One of the most common SysAdmin requirements when operating on a Server Farm is being able to remotely start, stop and restart an instance of IIS from a different node on the same network, maybe before issuing a backup task or a similar cron job.

The best way to achieve such result is using PowerShell commands: before you can do that, you need to set either the node you'll use to issue the command - we'll call it the Source PC - and the node hosting the IIS instance you want to manage - we'll call it the Target PC - as Trusted Hosts between each other: let's see how to do that.

Setup the TrustedHosts

From the Source PC, open a Command Prompt with administrative priviledges and then go to PowerShell by typing  powershell : once there, insert the following command - replacing the TARGET-HOST sample hostname  with the hostname or IP Address of the Target PC.

Do the same thing on your Target PC, replacing again the SOURCE-HOST sample hostname with the hostname or IP Address of the source PC:

As soon as you do that, you can run any PowerShell command between the two nodes which will be delivered via TCP. If you don't do that, you'll most likely incur in the following error message:

 

List of PowerShell Commands

Here are the relevant PowerShell command to issue, respectively, STOP, START and RESTART on the IIS instance installed on the target PC:

You can execute these command either from a PowerShell console or, if you prefer, from an elevated Command Prompt by adding a  powershell  at the start of each line. Again, remember to replace the TARGET-HOST sample hostname with the hostname or IP Address of the target PC.

You can also insert these commands in one or more PowerShell scripts (.ps1), which you can then launch from any other script: the choice is yours, depending on which script and or task you need to execute.

I hope that you'll find these infromation useful enough: that said, happy remote restarting!

 

 

Exit mobile version