1

我在詹金斯中构建了步骤“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'" "test" 成功启动。

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

4

1 回答 1

0

我用了:

Invoke-Command -ComputerName $Servers -credential $cred -ScriptBlock{} 

反而:

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

多谢你们!

于 2016-01-26T19:28:44.880 回答