我有一个带有PS脚本的Jenkins作业,如果它不可用,则创建Web站点。此脚本看起来很好并且执行没有错误。如果我必须创建一个我需要创建应用程序的网站,我正在寻找这个脚本的更新。我当前要求的屏幕截图的PFA。
Import-Module WebAdministration
Function WAPublish
{
Param(
[parameter(Mandatory=$true)]
[String]
$RELEASEDIR,
[parameter(Mandatory=$true)]
[String]
$DESTINATION,
[parameter(Mandatory=$true)]
[String]
$SERVER,
[parameter(Mandatory=$true)]
[String]
$SITE,
[parameter(Mandatory=$true)]
[String]
$HostName,
[parameter(Mandatory=$true)]
[String]
$SitePhysicalPath,
[parameter(Mandatory=$true)]
[String]
$WebPoolPhysicalPath,
[parameter(Mandatory=$true)]
[String]
$WebApplication,
[parameter(Mandatory=$true)]
[String]
$WebPoolDestPath
)
if(Test-Path "IIS:\Sites\$site\$WebApplication")
{
Write-Host "The provided website name is $site and it is a valid website`r`n" -ForegroundColor Cyan
Copy-Item "$RELEASEDIR\*" "\\$SERVER\$WebPoolPhysicalPath" -Force -Recurse
Write-Host "Deployment completed"
invoke-command -computername "$SERVER" -scriptblock {iisreset /RESTART}
}
else
{
Write-Host "There is not a website present in the name provided`r`n" -ForegroundColor Red
New-Item iis:\Sites\$SITE -bindings @{protocol="http";bindingInformation=":80:$HostName"} -physicalPath $SitePhysicalPath
New-WebApplication "$WebApplication" -Site "$SITE" -ApplicationPool "DefaultAppPool" -PhysicalPath "$WebPoolDestPath"
Copy-Item "$RELEASEDIR\*" "\\$SERVER\$WebPoolPhysicalPath" -Force -Recurse
invoke-command -computername "$SERVER" -scriptblock {iisreset /RESTART}
Exit
}
if ($error) { exit 1 }
}
WAPublish -RELEASEDIR "C:\Location" -DESTINATION "c$\Location" -SERVER "server" -SITE "LegalEntity" -HostName "Location" -SitePhysicalPath "C:\Location" -WebApplication "value" -WebPoolPhysicalPath "c$\Location" -WebPoolDestPath "C:\Location"