From a29b94e76443d0d84bb1d80f5486db0fa9aa2e10 Mon Sep 17 00:00:00 2001
From: ittchmh <ittchmh@gmail.com>
Date: Tue, 3 Mar 2020 12:22:28 +0200
Subject: [PATCH 1/2] Function Enable-SSHRemoting, Fix for windows

---
 EnableSSHRemoting.psm1 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/EnableSSHRemoting.psm1 b/EnableSSHRemoting.psm1
index 3bc3569..32d3db3 100644
--- a/EnableSSHRemoting.psm1
+++ b/EnableSSHRemoting.psm1
@@ -325,6 +325,12 @@ function Enable-SSHRemoting
         [switch] $Force
     )
 
+    # Detect platform
+    $platformInfo = [PlatformInfo]::new()
+    DetectPlatform $platformInfo
+    Write-Verbose "Platform information"
+    Write-Verbose "$($platformInfo | Out-String)"
+        
     # Non-Windows platforms must run this cmdlet as 'root'
     if (!$platformInfo.isWindows)
     {
@@ -353,12 +359,6 @@ function Enable-SSHRemoting
         }
     }
 
-    # Detect platform
-    $platformInfo = [PlatformInfo]::new()
-    DetectPlatform $platformInfo
-    Write-Verbose "Platform information"
-    Write-Verbose "$($platformInfo | Out-String)"
-
     # Detect SSH client installation
     if (! (Get-Command -Name ssh -ErrorAction SilentlyContinue))
     {

From 5dabe7e1132bdfc47c281c4d02688ab9008367d5 Mon Sep 17 00:00:00 2001
From: ittchmh <ittchmh@gmail.com>
Date: Tue, 3 Mar 2020 18:23:46 +0200
Subject: [PATCH 2/2] Install SSH Server and Client if not installed

---
 EnableSSHRemoting.psm1 | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/EnableSSHRemoting.psm1 b/EnableSSHRemoting.psm1
index 32d3db3..c66bb88 100644
--- a/EnableSSHRemoting.psm1
+++ b/EnableSSHRemoting.psm1
@@ -361,8 +361,12 @@ function Enable-SSHRemoting
 
     # Detect SSH client installation
     if (! (Get-Command -Name ssh -ErrorAction SilentlyContinue))
-    {
-        Write-Warning "SSH client is not installed or not discoverable on this machine. SSH client must be installed before PowerShell SSH based remoting can be enabled."
+    {   
+        $SSHCFound = $false
+        $SSHCFound = (Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0).Online
+        if (! $SSHCFound) {
+            Write-Warning "SSH client is not installed or not discoverable on this machine. SSH client must be installed before PowerShell SSH based remoting can be enabled."
+        }
     }
 
     # Detect SSHD server installation
@@ -370,6 +374,9 @@ function Enable-SSHRemoting
     if ($platformInfo.IsWindows)
     {
         $SSHDFound = $null -ne (Get-Service -Name sshd -ErrorAction SilentlyContinue)
+        If (! $SSHDFound) {
+            $SSHDFound = (Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0).Online
+        }
     }
     elseif ($platformInfo.IsLinux)
     {