I have multiple IIS servers running on different machines. These are all connected via remote web management service to a single machine where I do most of the management.

I want to automate some tasks via powershell. One task I can't find out how to do via powershell is add new connections to the machine where I am doing the remote management from.

Is there a powershell equivalent to this process here: https://blogs.msdn.microsoft.com/benjaminperkins/2014/08/05/configure-remote-iis-administration-for-iis-web-sites/ ?

  • What about PowerShell remoting?
    – Lex Li
    Aug 8 '19 at 13:30

The linked article has several steps. Let's see what Powershell can do for each of them.

The first step is to add the Management Service Role.

Per this Microsoft documentation:

Install-WindowsFeature -Name <feature_name> -computerName <computer_name> -Restart  

Using get-windowsfeature -computername, I find that the name of the IIS Management Service role is Web-Mgmt-Service, we'll use this:

Install-WindowsFeature -Name Web-Mgmt-Service -computerName <computer_name> -Restart  

Once installed, you need to start the Web Management Service.

This should do the trick:

Get-Service -ComputerName <computername> -Name WMSvc | Start-Service -Verbose

Change it to Automatic if you plan on using this feature often.

Get-Service -ComputerName <computername> -Name WMSvc | Set-Service -StartupType Automatic

Next, set the EnableRemoteManagement attribute in the Registry to 1

From this Microsoft scripting blog:

Use a combination of Get-Credential, Enter-PSSession, Push-Location, Set-Location, Set-ItemProperty, and Pop-Location.

This MCPMag.com article does the same thing, with slightly different commands.

Next, login to the server where you want to remote manage your IIS servers from. Open the IIS management console and click File -> Connect to a Server

I haven't found a Powershell way to do this part yet. It appears that saved connections are stored in %AppData%\Microsoft\WebManagement\\InetMgr.preferences, although the format isn't obvious. But the above commands will allow you to automate most of what you are asking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.