VMware Cloud Community
NicolasB57
Contributor
Contributor

Vro 8.11 avoid using jump PowerShell Server

Hi, 

I'm trying to open a PS Session on a remote server directly from VRO using PowerCli (7.12) 

My main goal is to :

1) get rid of the Powershell server host used as "jump" box 

2) use powershell code instead of javascript within vro

function Handler($context$inputs) {
    $inputsString = $inputs | ConvertTo-Json -Compress
    Write-Host "Inputs were $inputsString"

    $SecurePAssword = ConvertTo-SecureString "SecretPassword" -AsPlainText -Force
    $Creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "user@domain"$SecurePassword

    $ComputerName = "server1.domain.net"

    # Open a PS session to the VM
    $Session = New-PSSession -ComputerName $ComputerName -Name "TestSession"
    $SessionState = $Session.state
    write-host " PSSession State is : $SessionState"
    $output=@{status = 'done'}

    return $output
 
None of my attempts works, always getting :
 
ERROR
2023-03-23 05:24:16.101 -04:00ERROR\u001B[91mNew-PSSession: \u001B[0m/run/vco-polyglot/function/handler.ps1:23
2023-03-23 05:24:16.102 -04:00ERROR\u001B[96mLine |
2023-03-23 05:24:16.103 -04:00ERROR\u001B[96m 23 | \u001B[0m … $Session = \u001B[96mNew-PSSession -ComputerName "server1.domain.net\u001B[0m …
2023-03-23 05:24:16.104 -04:00ERROR\u001B[96m | \u001B[91m ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-03-23 05:24:16.105 -04:00ERROR\u001B[91m\u001B[96m | \u001B[91m
2023-03-23 05:24:16.106 -04:00ERROR\u001B[0m
 
Questions : is New-pssession "supported" from VRO to a windows server ?
using Invoke-Command -ComputerName server1.domain.net -Credential $Creds -ScriptBlock {hostname}
I get the same issue
Regards
Reply
0 Kudos
2 Replies
mayank_goyal
Enthusiast
Enthusiast

Same for me.



-
For more interesting content on Aria Automation, check my blog:
https://cloudblogger.co.in
Reply
0 Kudos
OSMOSIS99
Contributor
Contributor

Spoiler
Just echoing that I tried to do exactly the same thing as you for the same reasons, with the same result. 
Reply
0 Kudos