How To use WebAdministration for IIS7/7.5 using PowerShell


A simple how-to walkthrough of using powershell WebAdministration module for IIS to modify ApplicationHost.config.


Powershell is an excellent tool for running admin tasks on a server. WebAdministration an excellent out of the box powershell snap-in for configuring an mangaing IIS. This provider implements one virtual drive named IIS. It has three logical groupings AppPools,Sites and  SslBindings. We can also leverage the capabilities of the built in cmdlets for various operations.
Here we will be modifying "Ftp firewall Support" Data Channel port range settings and Firewall IP settings. Although this particular example is specific to that, these methods can be applied for any applicationHost.config setting.

 and this is would show these settings in IIS GUI


More Information

By default the "Execution Policy" powershell is "Restricted". So that means if you just run the import command or WebAdministration, you will get an Exception from powershell. We can set the this policy to "RemoteSigned" that will allow your custom scripts to be run but will not allow any internet downloaded script which is not trusted. We then do this by ruinning the command

PS <path>Set-ExecutionPolicy RemoteSigned get another error, "access denied". Did you forgot to run powershell as Administrator? Once you run as Administrator, this will successfully run now. Now import the module, it should be a success again.

Probably the first command you should know would be how to get help, here it is

PS <path>Get-help

for getting help about specific commandlets,

PS <path>Get-help <cmdlet name>

to get a list of all supported cmdlets,

PS <path>get-command -pssnapin WebAdministration

more information can be found at


Comments (3)

  1. geroge says:

    nice and simple. Thanks.

  2. Jignasha says:

    Good article

  3. Adam says:

    Is the get-webconfiguration cmdlet available in powershell 2.0 or does it require 3.0?

Skip to main content