Mr Andersson

Posts Tagged ‘iis

Note to self: Windows is getting sensitive with the IIS PowerShell provider

leave a comment »

Today I have struggled with some of the most basic automation tasks with the new IIS 7 web server; Creating a web site, application pool and application using a PowerShell script.

Starting out with this tutorial I managed to use the following sample to accomplish my task:

New-Item IIS:\Sites\DemoSite -physicalPath C:\DemoSite -bindings @{protocol=”http”;bindingInformation=”:8080:”}

Set-ItemProperty IIS:\Sites\DemoSite -name applicationPool -value DemoAppPool

New-Item IIS:\Sites\DemoSite\DemoApp -physicalPath C:\DemoSite\DemoApp -type Application

Set-ItemProperty IIS:\sites\DemoSite\DemoApp -name applicationPool -value DemoAppPool

Everything worked fine with the samples and I started to setup a testing environment on my machine. That involved setting up a local IIS 7, creating some directories in the file system for my test website etc.
All tasks seemed to work, but I repeatedly got the following error when trying to assign the correct application pool to the application:

Set-ItemProperty : Value cannot be null.
Parameter name: path
At C:\.....\WebSetup.ps1:37 char:17
+ Set-ItemProperty <<<< IIS:\Sites\DemoSite\Server -name applicationPool -value DemoAppPool

I tried to use other cmdlets to change the application pool setting, but with no success. I also tried to change all paths, the name of the web site etc. according to the sample. The sample code worked, but the error remained when executing Set-ItemProperty in my script.
I doubled checked the documentation, the sample, the value given to the parameter -Path – but it still failed.
I was just going to post a question about this matter in some forums when I figured it all out.

The name of the directories I created in the file system was using lowercase characters, but not the entries in the IIS configuration!

The cause of this must be the code in either the file system provider or the IIS provider for PowerShell. Some part of the code which is executed when invoking the Set-ItemProperty cmdlet is doing some case sensitive work..
The lesson and recommendation after this experience is that I will try to create both my entries in the file system and in the IIS configuration from the same script. 🙂

Windows is definitely getting more and more sensitive these days…

Advertisements

Written by anderssonjohan

August 20, 2009 at 19:47

Posted in scripting

Tagged with ,