Question

I have build step "Windows Powershell" in jenkins. In this step I run the next command: winrs -r:hostname -username:name -password:pass "C:\Configuration\rights.ps1" This command run script which located on remote host using winrm. Script contain next strings:

$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

After this command in output i see: powershell.exe "& 'C:\WINDOWS\TEMP\hudson1559950339055289195.ps1'" "test" successfully started.

And then i see executing icon and job not end but execute execute. I think that problem was in PS script last string "Exit" but not( Help me please!

Was it helpful?

Solution

I used:

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

instead:

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

Thanks guys!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top