dalehassinger
Contributor
Contributor

vRA 8.3 - I want to use invoke-vmscript in a Orchestrator action and a ABX action

Jump to solution
When I run this line of code in a orchestrator Action or a ABX action I get the error listed. What does vRA/vRO expect for a return code from the remote script?
 
Invoke-VMScript -VM $PSHost -ScriptType PowerShell -ScriptText $PSText -GuestUser $username -GuestPassword $HashiPW
 
This is what I have at the end of the script I am executing on remote server:
 
$output=@{status = 'done'}
return $output
 
What is required to return a success? The script will run but I always get this error in the action log.
 
2021-03-03 14:24:18.494 -05:00infoStarting PS Script.
2021-03-03 14:24:20.169 -05:00infoVERBOSE: Performing the operation "Invoke-VMScript" on target "WPSHOST".
2021-03-03 14:24:20.204 -05:00infoVERBOSE: 03/03/2021 19:24:20 Invoke-VMScript Finished execution
2021-03-03 14:27:33.585 -05:00error\u001B[91mInvoke-VMScript: \u001B[0m/run/vco-polyglot/function/handler.ps1:102
2021-03-03 14:27:33.586 -05:00error\u001B[96mLine |
2021-03-03 14:27:33.587 -05:00error\u001B[96m 102 | \u001B[0m \u001B[96mInvoke-VMScript -VM $PSHost -ScriptType PowerShell -ScriptText $P\u001B[0m …
2021-03-03 14:27:33.588 -05:00error\u001B[96m | \u001B[91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-03-03 14:27:33.589 -05:00error\u001B[91m\u001B[96m | \u001B[91m03/03/2021 19:27:33 Invoke-VMScript Response status code does not indicate success: 503 (Service Unavailable).
2021-03-03 14:27:33.590 -05:00error\u001B[0m
2021-03-03 14:27:33.591 -05:00info
0 Kudos
1 Solution

Accepted Solutions
FillDeUK
Enthusiast
Enthusiast

I understand what you are saying, and while I don't disagree, the issue I have is that the PS script runs fine and does exactly what I want it to, but the action still fails while trying to finish off..... It seems the the "behind the scenes" scripts need work....

View solution in original post

0 Kudos
9 Replies
FillDeUK
Enthusiast
Enthusiast

We had a similar error and sorted it by increasing the memory limit in the Action Runtime limits. Did you already try that?

0 Kudos
dalehassinger
Contributor
Contributor

I did increase memory and same error.  It seems like vRA/vRO doesn't get the return values from the remote script that is run. "Response status code does not indicate success: 503 (Service Unavailable)." Trying to determine if this is a bug in vRA 8.3.

 

2021-03-05 05:07:21.202 -05:00error\u001B[91mInvoke-VMScript: \u001B[0m/run/vco-polyglot/function/handler.ps1:103
2021-03-05 05:07:21.203 -05:00error\u001B[96mLine |
2021-03-05 05:07:21.204 -05:00error\u001B[96m 103 | \u001B[0m … $result = \u001B[96mInvoke-VMScript -VM DBH-222 -ScriptType bash -ScriptText \u001B[0m …
2021-03-05 05:07:21.205 -05:00error\u001B[96m | \u001B[91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-03-05 05:07:21.206 -05:00error\u001B[91m\u001B[96m | \u001B[91m03/05/2021 10:07:21 Invoke-VMScript Response status code does not indicate success: 503 (Service Unavailable).
2021-03-05 05:07:21.207 -05:00error\u001B[0m
0 Kudos
FillDeUK
Enthusiast
Enthusiast

It looks the same as our command that works fine. I presume you connected to the vCenter / host first?

0 Kudos
dalehassinger
Contributor
Contributor

Yes. I do connect to vCenter first. I can run the same code from my laptop or PS Host and it works ok every time. My SE runs the same command from his lab and also gets the same error. If you run the invoke-vmscript command OK what do you have as return code in the remote script?

0 Kudos
FillDeUK
Enthusiast
Enthusiast

If it any help, this is our full action script that returns correct info (in a strange array form, but I get it back).

All params are sent via the WF

Memory is set to 1024MB

    Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore -Confirm:$false

    $securePwd = $inputs.passwd | ConvertTo-SecureString -AsPlainText -Force 
       
    [pscredential]$credObject = New-Object System.Management.Automation.PSCredential($inputs.user, $securePwd)
   
    Connect-VIServer -Server $inputs.server -Protocol "HTTPS" -Credential $credObject

    $databack = Invoke-VMScript -VM $inputs.VM -ScriptText $inputs.scriptText -ScriptType Powershell -GuestUser $inputs.guestUser -guestPassword $inputs.guestPassword
   
    Disconnect-VIServer $inputs.server -Confirm:$false
    return $databack.scriptOutput
0 Kudos
dalehassinger
Contributor
Contributor

I tried your example and still not working for me.  I opened a support case and they have also not been able to resolve my issue yet. I changed how I am doing this process.  I am calling a vRO Workflow that runs a PS script on a remote server and that is working OK.

0 Kudos
FillDeUK
Enthusiast
Enthusiast

I've come to the conclusion that this PowerCli function is still in a beta form..... I've got different issues that VMware are looking at for me...

Maybe 8.4 will fix it...

0 Kudos
dalehassinger
Contributor
Contributor

I am going to create a Ubuntu Server and install PowerShell on that VM. Do all my script testing from that server. During a lot of my testing what I have discovered is if it works on a Windows Server doesn't mean it will work within vRA 8.x.

0 Kudos
FillDeUK
Enthusiast
Enthusiast

I understand what you are saying, and while I don't disagree, the issue I have is that the PS script runs fine and does exactly what I want it to, but the action still fails while trying to finish off..... It seems the the "behind the scenes" scripts need work....

0 Kudos