Using SSH from PowerShell

by Sep 7, 2018

PowerShell 6 (PowerShell Core) finally ships with SSH support: you can use SSH to connect to non-Windows machines for PowerShell remoting operations.

To just connect to switches and other devices using SSH, there is a free module available that adds a vast of useful new SSH commands to any PowerShell. This is how you’d download and install the module:

Install-Module -Name posh-ssh -Repository PSGallery -Scope CurrentUser

To see a list of the new commands, run this:

 
PS C:\> (Get-Command -Module posh-ssh).Name
Get-PoshSSHModVersion
Get-SFTPChildItem
Get-SFTPContent
Get-SFTPLocation
Get-SFTPPathAttribute
Get-SFTPSession
Get-SSHPortForward
Get-SSHSession
Get-SSHTrustedHost
Invoke-SSHCommand
Invoke-SSHCommandStream
Invoke-SSHStreamExpectAction
Invoke-SSHStreamExpectSecureAction
New-SFTPFileStream
New-SFTPItem
New-SFTPSymlink
New-SSHDynamicPortForward
New-SSHLocalPortForward
New-SSHRemotePortForward
New-SSHShellStream
New-SSHTrustedHost
Remove-SFTPItem
Remove-SFTPSession
Remove-SSHSession
Remove-SSHTrustedHost
Rename-SFTPFile
Set-SFTPContent
Set-SFTPLocation
Set-SFTPPathAttribute
Start-SSHPortForward
Stop-SSHPortForward
Test-SFTPPath
Get-SCPFile
Get-SCPFolder
Get-SFTPFile
New-SFTPSession
New-SSHSession
Set-SCPFile
Set-SCPFolder
Set-SFTPFile 
 

Twitter This Tip! ReTweet this Tip!