使用powershell创建虚拟目录,app pool

时间:2015-06-09 05:07:39

标签: powershell

使用电源shell创建网站,应用程序池。将创建的应用程序池设置为创建的网站。将应用程序池托管管道模式更改为经典。我需要使用power shell进行上述3件事。

使用以下代码创建应用程序池,工作正常

导入模块Web管理 $ iisAppPoolName =" TestAppPool" $ iisAppPoolDotNetVersion =" v4.0"

    cd IIS:\AppPools\

    $appPool = New-Item $iisAppPoolName
    $appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $iisAppPoolDotNetVersion

1 个答案:

答案 0 :(得分:0)

    $appPoolName = "your app pool name"
    $managedRunTimeVersion = "v4.0"  # your .net framework
    $managedPipelineMode = 1  # ([int] [Microsoft.Web.Administration.ManagedPipelineMode]::Classic)
    $physicapPath = "the physical path for your application"

    $IISPath = "IIS:\AppPools\$appPoolName"

    if (dir $IISPath -ErrorAction SilentlyContinue)
        { Write-Output "`t`t$($MyInvocation.InvocationName): Application pool `'$appPoolName`' already exists"; return }

    New-Item $IISPath -Force | Out-Null

    Set-ItemProperty $IISPath -name ManagedRunTimeVersion -value $managedRunTimeVersion
    Set-ItemProperty $IISPath -name ManagedPipelineMode -value $managedPipelineMode

    New-Item $IISPath -physicalPath $physicalPath -type Application -Force | Out-Null
    Set-ItemProperty $IISPath -name applicationPool -value $appPoolName