0
我需要检查IIS中是否存在站点。如果退出,那么我需要执行PS脚本,如果没有,那么我需要创建一个新名称的IIS网站并执行PS脚本。检查IIS网站是否存在并将项目复制到物理路径
我在这里写了一些东西,但造成了很少的错误。
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
)
if(Test-Path IIS:\Sites\$site)
{
Write-Host "The provided website name is $site and it is a valid website`r`n" -ForegroundColor Cyan
Get-ChildItem "$RELEASEDIR\*"
Copy-Item "$RELEASEDIR\*" "\\$SERVER\$DESTINATION" -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-Website –Name $SITE –PhysicalPath "$DESTINATION"
if ($error) { exit 1 }
Get-ChildItem "$RELEASEDIR\*"
Copy-Item "$RELEASEDIR\*" "\\$SERVER\$DESTINATION" -Force -Recurse
Write-Host "Deployment completed"
invoke-command -computername "$SERVER" -scriptblock {iisreset /RESTART}
Exit
}
if ($error) { exit 1 }
}
WAPublish -RELEASEDIR "C:\Location" -DESTINATION "c$\test" -SERVER "server" -SITE "test"
错误
New-Website : Parameter 'PhysicalPath' should point to existing path.
At C:\Release\RPCPS\WebApiPublish-2.ps1:29 char:9
+ New-Website –Name $SITE –PhysicalPath "$DESTINATION"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-Website], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.IIs.PowerShell.Provider.NewWebsiteCommand
我仍然收到同样的错误。 新网站:参数'PhysicalPath'应指向现有路径。 在C:\ Release \ RPCPS \ test.ps1:34 char:13 + New-Website -Name $ SITE -PhysicalPath“$ DESTINATION” + ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:(:) [新网站] ,ArgumentException + FullyQualifiedErrorId:System.ArgumentException,Microsoft.IIs.PowerShell.Provider.NewWebsiteCommand – Kally
$ DESTINATION的值是什么? –