If you have never installed any modules from PS Gallery you can run the below command so that you do not get the Untrusted Error.

Set-PSrepository -Name PSGallery -InstallationPolicy Trusted

Step 1:
Need to change the Execution Policy or you will throw an Error

Set-ExecutionPolicy Unrestricted CurrentUser

Step 2:
Need to go ahead and install the Posh-SSH module

We are adding on the -RequiredVersion switch as that is the stable version. There is a 2.1 version, but suggested version and this guide uses the 2.0.2 version.

Install-Module Posh-SSH -RequiredVersion 2.0.2

Step 3:
Import the module of Posh-SSH to make the commandlets available for use.

Import-Module Posh-SSH

Now you can verify this by running a Get-InstalledModule command and should output the Posh-SSH Module


Just for to see what we can do:
Let us now go ahead and run the Get-Command and see what Commandlets and functions are available within the Posh-SSH module

Get-Command – Module Posh-SSH

Step 4:
Initiate an SSH Session with the following command

New-SSHSession -ComputerName -AcceptKey

Even though the switch says ComputerName you can go ahead and put an Ip Address there. We are also going ahead and added the -AcceptKey to accept the RSA key of that SSH session. A Credentials popup window will come up to fill in the login creds, and this can be automated. For now we will just manually fill in the credentials.

Now you have established a session with your remote SSH enabled device. Be on the look out for another post on how to use Posh-SSH with a SonicWall UTM appliance.