由于以下错误,Powershell-CLSID失败:80040154类未注册

时间:2017-02-24 11:53:17

标签: powershell jenkins

从Jenkins作业执行以下PS脚本时,我遇到了以下错误。相同的脚本运行良好如果我从服务器手动执行。 我的剧本正在做什么 -

我需要检查IIS中是否存在某个站点。如果退出,那么我需要执行PS脚本,如果没有,那么我需要创建一个具有该名称的新IIS网站并执行PS脚本。

我的PS脚本是

=IF(B36="","",CHAR(11)&B36&CHAR(11))

错误日志 -

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]
    $PhysicalPath
    )
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-Item iis:\Sites\$SITE -bindings @{protocol="http";bindingInformation=":80:$HostName"} -physicalPath $PhysicalPath
        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 "$env:WEBAPISERVER" -SITE "$env:SITE" -HostName "$env:HOSTNAME" -PhysicalPath "C:\test"

0 个答案:

没有答案