How do I set the .NET Framework Version when using New-WebAppPool?

旧城冷巷雨未停 提交于 2019-11-30 04:37:05
Keith Hill

With the WebAdministration module loaded try this on a pool that you've created:

Set-ItemProperty IIS:\AppPools\<pool_name> managedRuntimeVersion v4.0
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 detail script from how to set the IIS Application Pool to specify version of the .NET Framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!