Skip to content

Commit 473539b

Browse files
committed
install and unintall scripts for sshd
1 parent 8c4d3f2 commit 473539b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
$scriptpath = $MyInvocation.MyCommand.Path
2+
$scriptdir = Split-Path $scriptpath
3+
4+
$sshdpath = Join-Path $scriptdir "sshd.exe"
5+
6+
if (-not (Test-Path $sshdpath)) {
7+
throw "sshd.exe is not present in script path"
8+
}
9+
10+
if (Get-Service sshd -ErrorAction SilentlyContinue)
11+
{
12+
Stop-Service sshd
13+
sc.exe delete sshd 1> null
14+
}
15+
16+
New-Service -Name sshd -BinaryPathName $sshdpath -Description "SSH Deamon" -StartupType Manual | Out-Null
17+
Write-Host -ForegroundColor Green "sshd successfully installed"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if (Get-Service sshd -ErrorAction SilentlyContinue)
2+
{
3+
Stop-Service sshd
4+
sc.exe delete sshd 1> null
5+
Write-Host -ForegroundColor Green "sshd successfully uninstalled"
6+
}
7+
else {
8+
Write-Host -ForegroundColor Yellow "sshd service is not installed"
9+
}
10+

0 commit comments

Comments
 (0)