< Back

Invoke-SSHCommand

Sat Jan 18, 2020 7:57 pm

NAME Invoke-SSHCommand



SYNOPSIS

Executes a given command on a remote SSH host.





SYNTAX

Invoke-SSHCommand [-SessionId] <Int32[]> [-Command] <String> [[-TimeOut] <Int32>] [[-ThrottleLimit] <Int32>]

[-EnsureConnection] [<CommonParameters>]



Invoke-SSHCommand [-SSHSession] <SshSession[]> [-Command] <String> [[-TimeOut] <Int32>] [[-ThrottleLimit] <Int32>]

[-EnsureConnection] [<CommonParameters>]





DESCRIPTION

Executes a given command on a remote SSH host given credentials to the host or using an existing SSH Session.





PARAMETERS

-Command <String>

Command to execute in remote host.



Required? true

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-SessionId <Int32[]>

SSH Session Id of an exiting session.



Required? true

Position? 0

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-EnsureConnection [<SwitchParameter>]

Ensures a connection is made by reconnecting before command.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-TimeOut <Int32>

Time out in seconds to wait for the command to return a value.



Required? false

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ThrottleLimit <Int32>

@{Text=}



Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-SSHSession <SshSession[]>

SSH Session object.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

SSH.SshSession[]







OUTPUTS



NOTES





AUTHOR: Carlos Perez carlos_perez@darkoprator.com



-------------------------- EXAMPLE 1 --------------------------



Invoke-SSHCommand -Command "uname -a" -SessionId 0,2,3





Host : 192.168.1.163

Output : Linux debian6 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64 GNU/Linux



ExitStatus : 0



Host : 192.168.1.155

Output : Linux ole6 2.6.39-300.17.1.el6uek.x86_64 #1 SMP Fri Oct 19 11:29:17 PDT 2012 x86_64 x86_64 x86_64

GNU/Linux



ExitStatus : 0



Host : 192.168.1.234

Output : Linux ubuntusrv 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64

GNU/Linux



ExitStatus : 0







RELATED LINKS

Online Version: https://github.com/darkoperator/Posh-SS ... aster/docs