IISAdministration PowerShell Cmdlets (New feature in Windows 10 / Server 2016)

With Windows 10, IIS Team is releasing a new and simplified IISAdministration module side by side with the existing WebAdministration Cmdlets. There are many reasons behind the decision to release an entirely new PowerShell Cmdlet module and here are a few of them:

  • IISAdministration will scale better in scripts that take a long time to run with WebAdministration.
  • You can now get a direct reference to an instance of Microsoft.Web.Administration.ServerManager object and do anything that you can do in Microsoft.Web.Administration namespace alongside your scripts.
  • PowerShell pipeline compatibility was the driving force behind the design of many cmdlets. As such, IISAdministration works much better with PowerShell Pipeline.

The version of the Cmdlets we are releasing in Windows 10 is a rough version with room for improvement. Our targeted release is for Windows Server 2016 for the finished and polished product. The reason we release this now is to get feedback from real PowerShell users and IIS Administrators in the industry, answer any questions and receive suggestions about not only the existing functionality but also potentially for new functionality our users would want from IIS Administration as it pertains to PowerShell.

Here, I will try to give some examples on the usage of the new provider:

Pipelining

PS:>Get-IISConfigSection -SectionPath "system.webServer/defaultDocument" | Get-IISConfigCollection -CollectionName "files" | New-IISConfigCollectionElement -ConfigAttribute @{"Value" = "MyDefDoc.htm"}

Get-IISConfigSection is at the beginning of most pipelines and in the specific example above, we are first getting the "system.webServer/defaultDocument" section (Case Sensitive!), then get the files collection, and finally get a collection element with the given attribute value.

PS:>$ConfigSection = Get-IISConfigSection -SectionPath "system.applicationHost/sites"

PS:>Get-IISConfigCollection $configSection | Get-IISConfigCollectionElement -ConfigAttribute @{"Name"="Default Web Site"} | Get-IISConfigAttributeValue -AttributeName "State"

This one is more of a hybrid example where the section is first put into a variable, then used in the pipeline.

Simple Commands

The number of simple commands are greatly reduced to a few. The examples include Get-IISSite and Get-IISAppPool. Other simple operations for which the commands do not exist can be performed through pipeline operations.

PS:> Get-IISAppPool

Name                       Status       CLR Ver  Pipeline Mode     Start Mode
----                           ------       -------     -------------          ----------
DefaultAppPool       Started      v4.0        Integrated           OnDemand 

Get-IISServerManager

PS:>$sm = Get-IISServerManager

PS:>$sm.ApplicationPools["DefaultAppPool"].Recycle()

As you can see, once you have access to the server manager, the sky is the limit.

Start-IISCommitDelay / Stop-IISCommitDelay

By enclosing your operations between these commands, you can make sure that your changes are committed at the same time.

These are only a handful of examples of what you can do with the new provider. Visit TechNet for the complete documentation and more examples.

5 Comments

  • Will this be released under an open-source license, perhaps posted on GitHub where others can contribute?
    Is the Win2016 release a for-sure on finalizing this module, or is that more a target? How will subsequent releases be made available?
    Can this be made available for downlevel operating systems? The .NET class in question has been around since IIS7, so it seems in theory that the code would run on older versions of Windows.

  • Down level release is certainly something we are considering. Server 2016 release is certain, since we already released it with Win10. I don't have any information on whether this would or could be released under open source. Would that be something the end users will be interested in? What contributions would you be making to it? In other words, what is missing from this that you'd like to add to?

  • Baris,

    Where do we get this module from? Someone with Windows 10 in our org says it's not in his list of available modules.

    Also, what is the best avenue for providing feedback once I get my hands on it?

    I would definitely be interested in a down level release. Also, it doesn't look like it currently in the documentation, but is the ability to remotely manage an IIS server in the works as well?

  • Jared, IIS must be installed on Turn Windows Features on/off to get the PowerShell module. Remote management is possible with the built-in feature of PowerShell (Remote PowerShell Tab) but not with the Cmdlets directly.

    For feedback, you can use these comments or send an email directly to me (let me know if you can't get to the email address).

  • I've seen a few questions on how the PG can be reached for comments. You can reach us at IISAdministration at %MSFT% dot com. (Where %MSFT% expands to the full name of the company).

    We are fighting with the spam but I think they may have found a solution to the problem so for now we will wait and see.

Comments have been disabled for this content.