This article will show you how to run SSH commands from PowerShell and executing commands against Linux hosts directly from the PowerShell console.
In order to use SSH within PowerShell we need to Install a PowerShell module called Posh-SSH.
To run the module you will need a Windows 10 client or Windows Server 2016.
Note: To run this on Windows Server 2012 or Windows 7 Install Windows Management Framework 5.0 and run the line below before running the Install-module cmdlet.
Install-PackageProvider -Name NuGet -Force
To start the process I start PowerShell as Administrator and type:
Wait for the Installation to finish
Once done you can see all the available cmdlets by typing:
Get-command -module posh-ssh
To connect to my Azure Linux VM I type:
New-sshsession <ip address>
Take Note of the session ID you will need It to run the commands against the host
To run commands against the Linux host I use:
Invoke-SSHCommand -SessionId 0 date
Here Is another example