【发布时间】:2018-09-25 08:49:25
【问题描述】:
这是用于创建 IIS 站点和应用程序池的 powershell 脚本。它成功创建了站点和应用程序池,但我没有看到站点文件夹已创建。为什么?
$iisAppPoolName = "webtest.abc.com"
$iisAppPoolDotNetVersion = "v4.0"
$iisAppPoolManagedPipeLineMode = "0"
$iisAppName = "webtest.abc.com"
$directoryPath = "C:\inetpub\wwwroot\" + $iisAppPoolName
$SiteFolder = Join-Path -Path 'C:\inetpub\wwwroot' -ChildPath $iisAppName
#navigate to the app pools root
cd IIS:\AppPools\
#check if the app pool exists
if (!(Test-Path $iisAppPoolName -pathType container))
{
#create the app pool
$appPool = New-Item $iisAppPoolName
$appPool | Set-ItemProperty -Name "managedRuntimeVersion" -Value $iisAppPoolDotNetVersion
$appPool | Set-ItemProperty -Name "managedPipelineMode" -Value $iisAppPoolManagedPipeLineMode
}
#navigate to the sites root
cd IIS:\Sites\
#check if the site exists
if (Test-Path $iisAppName -pathType container)
{
return
}
#create the site
$iisApp = New-Item $iisAppName -bindings @{protocol="http";bindingInformation=":80:" + $iisAppName} -physicalPath $SiteFolder
$iisApp | Set-ItemProperty -Name "applicationPool" -Value $iisAppPoolName
【问题讨论】:
标签: powershell iis