Add enable-ssh-server.ps1

This commit is contained in:
Markus Fleschutz
2021-03-25 17:24:31 +01:00
parent 8f59a7fd0f
commit 565c45febe
3 changed files with 21 additions and 0 deletions

19
Scripts/enable-ssh-server.ps1 Executable file
View File

@ -0,0 +1,19 @@
#!/bin/powershell
<#
.SYNTAX ./enable-ssh-server.ps1
.DESCRIPTION enables the SSH server
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
Add-WindowsCapability -Online -Name OpenSSH.Server*
Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'
write-host -foregroundColor green "OK - SSH server enabled"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}