While trying to write some scripts to manage our IIS sites, I came across some weird behavior with ManagedPipelineMode in IIS. My code is pretty general and uses Get-ItemProperty to read the old value, and then Set-ItemProperty to update it if that is not the value we want.
However, if I ran this:
Get-ItemProperty "IIS:\AppPools\MyAppPool" "managedPipelineMode"
I am returning the string Classic . However, if I ran this:
Set-ItemProperty "IIS:\AppPools\MyAppPool" "managedPipelineMode" "Classic"
I am returning the Classic is not a valid value for Int32 error.
So, I know that I can set the value using ([int][Microsoft.Web.Administration.ManagedPipelineMode]::Classic) , but I donβt understand why the type seems different when using Get-ItemProperty vs Set-ItemProperty , or how I can request this to behave consistently.
Note. I really don't want to put a special case for ManagedPipelineMode, since every other property seems to behave as expected. So, two questions:
- What kind of strange behavior is this that allows you to assign the
string property when reading, but int when setting? Does this apply to all transfers? - Is there a way to read / write this property using the same type, so I can write code that can read the value, check if we want it, and if not, update it?
source share