From ab693c7dbfe97d28c68d87036c12c0d89c4fda0d Mon Sep 17 00:00:00 2001 From: Chris Nutter Date: Wed, 1 Nov 2023 18:42:13 -0700 Subject: [PATCH] Update Script.ps1 --- Script.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Script.ps1 b/Script.ps1 index 55ba8e1..2dc84af 100644 --- a/Script.ps1 +++ b/Script.ps1 @@ -44,3 +44,19 @@ powercfg -change -standby-timeout-ac 0 powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c powercfg /hibernate on powercfg -change -monitor-timeout-ac 30 + +# Install OpenSSH +Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*' +Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 +Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 + +Start-Service sshd + +Set-Service -Name sshd -StartupType 'Automatic' + +if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { + Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." + New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 +} else { + Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." +} \ No newline at end of file