Can I create sites and application pools on a remote IIS server using Powershell?

1.6k views Asked by At

I have a Powershell script that sets up new web servers. At the moment, you have to connect to the server via Remote Desktop and run the script locally; it uses the WebAdministration module and is full of pseudopaths like IIS:/Sites\www.mysite.com\ and so on.

Can I use the same WebAdministration module to manage a remote server? I'd hoped something like get-childitem IIS://myserver/Sites/ might work but can't find any documentation or examples of using this module against a remote server.

1

There are 1 answers

0
PhonicUK On

What you do is set up powershell remoting (before you start with WebAdministration at all). This has to be configured on the remote server first though as it's not enabled by default.

You'll need to run Enable-PSRemoting –force while runing PS as admin to turn it on, and there's a few other minor bits to get the security sensible. There's a decent technet article on this at http://technet.microsoft.com/en-us/magazine/ff700227.aspx

Once you've done that, you can invoke a command on the remote machine using:

Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME