Written by 5:47 pm Microsoft, Microsoft Azure, PowerShell, Windows, Windows Server • 25 Comments

Using SSH with PowerShell

PowerShell SSH Session

Microsoft announced that they will support SSH using PowerShell in Windows 10. Until now Microsoft has a good solution for this, there is a third party solutions called Posh-SSH. To use SSH in PowerShell you first have to install the Posh-SSH PowerShell Module from the PowerShell Gallery. Make sure you are running Windows 10 or you have the Windows Management Framework 5 installed.

If you want to use SSH with PowerShell 6, you read my blog here: Using SSH with PowerShell 6

You can now find the Posh-SSH Module and install it:

PowerShell SSH Installation

 
Install-Module Posh-SSH

You now have several PowerShell SSH cmdlets available:

PowerShell SSH cmdlets

Now you can create a new SSH Session using the following cmdlet (Password based authentication)

PowerShell SSH Session

 
New-SSHSession -ComputerName "thomasmaurer.azure.cloudapp.net" -Credential (Get-Credential)

You can now simply run commands against this session or use SCP to copy files.

PowerShell SSH Commands

 
Invoke-SSHCommand -Index 0 -Command "uname"

I hope this helps you using SSH with PowerShell. If you have any questions, please write it in the comments. Also check out my other blogs and see how SSH is integrated in Windows 10.

Tags: , , , , , , , , , Last modified: April 4, 2019
Close Search Window
Close