How to install version of .NET Framework when using New-WebAppPool?

I want to see how I can use the IIS PowerShell New-WebAppPool cmdlet to indicate the version of the .NET Framework being used. Currently, v2.0 is used by default, however, I am using MVC, and this will not work, because it is a v4.0 function. We really want each site to have its own application pool, and it seems to us that we should create these pools manually due to the inability to configure them through a script. Is there a way to automate this?

I am afraid that the answer will be β€œyou cannot”, because the documentation does not offer any options for customization, and Google becomes squat; this gives me the impression that only configuring sites according to the script is acceptable, and something about setting up application pools is simply not done. I can’t imagine why not - if you automate one big part of the process, why can't you automate another main part?

Anyone who could figure out how to do this with PowerShell would help me a lot.

+53
windows powershell iis application-pool .net-framework-version
Nov 19 '10 at 20:25
source share
2 answers

With the WebAdministration module loaded, try this in the pool you created:

Set-ItemProperty IIS:\AppPools\<pool_name> managedRuntimeVersion v4.0 
+90
Nov 19 '10 at 21:00
source share
 Import-Module WebAdministration #Get all web sites dir IIS:\Sites | ForEach-Object { #Go to the app pools root cd IIS:\AppPools\ if (!(Test-Path $_.Name -pathType container)) { #Create the app pool and set .net framework version $appPool = New-Item $_.Name $appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $IISAppPoolDotNetVersion #Go to the web sites root cd IIS:\Sites\ $iisApp = Get-Item $_.Name $iisApp | Set-ItemProperty -Name "applicationPool" -Value $_.Name } else { $dotNetVersion = (Get-ItemProperty $_.Name managedRuntimeVersion).Value if ($dotNetVersion -ne $IISAppPoolDotNetVersion){ #Get the app pool and set .net framework version $appPool = Get-Item $_.Name $appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $IISAppPoolDotNetVersion } } } 

You can download the script detail from how to install the IIS application pool to indicate the version of the .NET Framework

0
Nov 15 '16 at 5:38
source share



All Articles