VMware Cloud Community
jvm2016
Hot Shot
Hot Shot
Jump to solution

posh-ssh

Hi Luc ,

is there any known issue with posh-ssh module

i am trying to use invoke-sshcommand using session id 0 (that should be the first session id )

i belive 0 should be considered as the session id .(ZERO HAS GREAT SIGNIFICANCE IN MATHEMATICS)

PS C:\> $session_vcsa=New-SSHSession -ComputerName vcsa-01a.corp.local -Credential $cred_root

PS C:\> $session_vcsa.SessionId

0

PS C:\> $conlib=Invoke-SSHCommand -Command "service-control --status vmware-content-library" -SessionId $session_vcsa_id

Invoke-SSHCommand : Cannot bind argument to parameter 'SessionId' because it

is null.

At line:1 char:97

+ ... -control --status vmware-content-library" -SessionId $session_vcsa_id

+                                                          ~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Invoke-SSHCommand], ParameterB

   indingValidationException

    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,I

   nvoke-SSHCommand

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Not sure what you are doing there, but the error states that variable $session_vcsa_id contains $null, not 0.
I don't see you assigning any value to $session_vcsa_id, hence it contains $null (as any uninitialised, non-typed variable)

In fact, when I test with the number 0, it works

SSHCommand -Command "service-control --status vmware-content-library" -SessionId 0


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Not sure what you are doing there, but the error states that variable $session_vcsa_id contains $null, not 0.
I don't see you assigning any value to $session_vcsa_id, hence it contains $null (as any uninitialised, non-typed variable)

In fact, when I test with the number 0, it works

SSHCommand -Command "service-control --status vmware-content-library" -SessionId 0


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

i am going to check this again .i think i did not pass the right variable which has value zero in it .thats why it took null.

however i am getting below

PS C:\Windows\system32> New-SSHSession -ComputerName vcsa-01a.corp.local -Credential(Get-Credential)

cmdlet Get-Credential at command pipeline position 1

Supply values for the following parameters:

New-SSHSession : Permission denied (keyboard-interactive).

At line:1 char:1

+ New-SSHSession -ComputerName vcsa-01a.corp.local -Credential(Get-Cred ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : SecurityError: (Renci.SshNet.SshClient:SshClient) [New-SSHSessio

   n], SshAuthenticationException

    + FullyQualifiedErrorId : SSH.NewSshSession

even i cant login to vami with root .

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That looks like a credential issue.
Can you add the -Verbose switch?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jvm2016
Hot Shot
Hot Shot
Jump to solution

It worked fine when I tested last .variable had value zero and hence session I’d zero.

0 Kudos