Powershell 詹金斯的工作一直在执行

Powershell 詹金斯的工作一直在执行,powershell,jenkins,winrm,Powershell,Jenkins,Winrm,我在詹金斯建立了Windows Powershell。在此步骤中,我运行下一个命令: winrs-r:hostname-username:name-password:pass C:\Configuration\rights.ps1 此命令使用winrm运行位于远程主机上的脚本。脚本包含以下字符串: $Acl = Get-Acl "C:\folder\test" $Ar = New-Object system.security.accesscontrol.filesystemaccessrule

我在詹金斯建立了Windows Powershell。在此步骤中,我运行下一个命令: winrs-r:hostname-username:name-password:pass C:\Configuration\rights.ps1 此命令使用winrm运行位于远程主机上的脚本。脚本包含以下字符串:

$Acl = Get-Acl "C:\folder\test"
$Ar = New-Object  system.security.accesscontrol.filesystemaccessrule("IIS_IUSRS","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$Acl.SetAccessRule($Ar)
Set-Acl "C:\folder\test" $Acl

C:\Windows\system32\inetsrv\AppCmd.exe Start Site test

Exit
在输出中执行此命令后,我看到: powershell.exe和“C:\WINDOWS\TEMP\hudson1559950339055289195.ps1” 测试已成功启动

然后我看到执行图标和作业不是结束而是执行。 我认为问题出在PS脚本的最后一个字符串退出中,但不是 请帮帮我

我用了:

Invoke-Command -ComputerName $Servers -credential $cred -ScriptBlock{} 
相反:

winrs -r:hostname -username:name -password:pass "C:\Configuration\rights.ps1"

谢谢大家

您应该添加一些调试输出,以帮助识别出现问题的代码。请提供更多信息。代码工作正常。命令C:\Windows\system32\inetsrv\AppCmd.exe Start Site test具有下一个输出:“C:\Windows\TEMP\hudson1559950339055289195.ps1”测试已成功启动。我使用了:Invoke命令-ComputerName$Servers-credential$cred-ScriptBlock{}代替:winrs-r:hostname-username:name-pass C:\Configuration\rights.ps1谢谢