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

View File

@ -34,6 +34,7 @@ display-time.ps1, displays the current time for 10 seconds by default
download.ps1, downloads the file/directory from the given URL
enable-crash-dumps.ps1, enables the writing of crash dumps
enable-god-mode.ps1, enables the god mode (adds a new icon to the desktop)
enable-ssh-server.ps1, enables the SSH server
encrypt-file.ps1, encrypts the given file
fetch-repo.ps1, fetches updates for the current/given Git repository (including submodules)
fetch-repos.ps1, fetches updates for all Git repositories under the current/given directory (including submodules)

1 Script Description
34 download.ps1 downloads the file/directory from the given URL
35 enable-crash-dumps.ps1 enables the writing of crash dumps
36 enable-god-mode.ps1 enables the god mode (adds a new icon to the desktop)
37 enable-ssh-server.ps1 enables the SSH server
38 encrypt-file.ps1 encrypts the given file
39 fetch-repo.ps1 fetches updates for the current/given Git repository (including submodules)
40 fetch-repos.ps1 fetches updates for all Git repositories under the current/given directory (including submodules)

View File

@ -37,6 +37,7 @@ Mega Collection of PowerShell Scripts
* [check-swap-space.ps1](Scripts/check-swap-space.ps1) - checks the swap space for free space left
* [check-windows-system-files.ps1](Scripts/check-windows-system-files.ps1) - checks the validity of the Windows system files (requires admin rights)
* [enable-crash-dumps.ps1](Scripts/enable-crash-dumps.ps1) - enables the writing of crash dumps
* [enable-ssh-server.ps1](Scripts/enable-ssh-server.ps1) - enables the SSH server
* [hibernate.ps1](Scripts/hibernate.ps1) - enables hibernate mode for the local computer (requires admin rights)
* [list-drives.ps1](Scripts/list-drives.ps1) - lists all drives
* [list-network-shares.ps1](Scripts/list-network-shares.ps1) - lists the network shares of the local computer

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
}