From f52b18439c78f5f9da80fc691d60c6dd5df26b1b Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 9 Feb 2021 19:08:24 +0000 Subject: [PATCH] update ssh script --- scripts/OpenSSHServerInstall.ps1 | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/scripts/OpenSSHServerInstall.ps1 b/scripts/OpenSSHServerInstall.ps1 index 4c52ffee..7d2a3f73 100644 --- a/scripts/OpenSSHServerInstall.ps1 +++ b/scripts/OpenSSHServerInstall.ps1 @@ -1,23 +1,8 @@ -##Check if openssh is installed -if((Get-WindowsCapability -Online | ? Name -like OpenSSH*).State -eq "Installed") - { - Write-Output "OpenSSH Server is installed." - } - -else - - { - Write-Output "OpenSSH Server is NOT installed."; - ## Install SSH - Add-WindowsCapability -Online -Name "OpenSSH.Server~~~~0.0.1.0" - - ## Set SSH service to start automatically - Set-Service -Name sshd -StartupType "Automatic" - - ## Allow SSH through firewall on all profiles - Get-NetFirewallRule -Name *ssh* - - ## Start SSH service - Start-Service sshd - - } +if((Get-WindowsCapability -Online | ? Name -like OpenSSH.Server*).State -eq "Installed") { + Write-Output "OpenSSH Server is already installed." +} else { + Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 + Set-Service -Name sshd -StartupType 'Automatic' + Start-Service sshd +} +Get-WindowsCapability -Online | Where-Object -Property Name -Like "OpenSSH*"