Changing .NET CLR Version in IIS Application Pool settings

Hello,

I made a script that creates a new user, new website, new application pool, and amends the managedRuntimeVersion of the application pool from “v4.00” to “No Managed Code”. This is the part of the code that does the job:

#Creates and amends AppPool

Import-Module WebAdministration

New-Item -Path IIS:\AppPools$username

Set-ItemProperty -Path IIS:\AppPools$username -Name managedRuntimeVersion -Value “No Managed Code”

Set-ItemProperty iis:\apppools$username -name processModel -value @{userName=$AppPoolUsername;password=$AppPoolPassword;identitytype=3}

The issue is that when I open the newly created website the apppool stops automaticaly. What I found is that when I manually change from “No Managed Code” to “v4.00”, click apply, then change again to “No Managed Code” from the dropdown - it works just fine.

The conclusion is that when I set it to “No Managed Code” from the shell, it crashes the application pool. If I change it from the dropdown menu in advanced settings - it works.

Could you please help me on this?

Hi Daniel, Welcome to the forum!

First and foremost, when posting code please use the preformatted option. It’s the </> icon. It may be hidden under the settings wheel depending on your screen size, etc. It makes it much easier to help.

Second, you’ve provided a code snippet that is incomplete. We have no clue what’s in $username, $AppPoolUsername, or $appPoolPassword. It makes it much easier to assist you if we have a working code sample. Plus there could be obvious issues with what you’re storing in the variables that we won’t have a clue about.

Finally, with my testing you don’t provide the value “No Managed Code”. After setting this and looking in your dropdown you should see two entries for “No Managed Code” which is a big clue that you are adding a 4th, invalid option. I recommend you try just setting the value to an empty string.

#Creates and amends AppPool
Import-Module WebAdministration

New-Item -Path IIS:\AppPools$username

Set-ItemProperty -Path IIS:\AppPools$username -Name managedRuntimeVersion -Value ""

Set-ItemProperty iis:\apppools$username -name processModel -value @{userName=$AppPoolUsername;password=$AppPoolPassword;identitytype=3}

Hello krzydoug,

Thank you for your note - I found the icon :slight_smile:

I pasted only that part of the code that is about the application pool. I tested the solution provided and it works.

Thank you for your time.
Daniel