install and unintall scripts for sshd

This commit is contained in:
manojampalam 2016-04-03 21:06:52 -07:00
parent 8c4d3f23ab
commit 473539b9bf
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,17 @@
$scriptpath = $MyInvocation.MyCommand.Path
$scriptdir = Split-Path $scriptpath
$sshdpath = Join-Path $scriptdir "sshd.exe"
if (-not (Test-Path $sshdpath)) {
throw "sshd.exe is not present in script path"
}
if (Get-Service sshd -ErrorAction SilentlyContinue)
{
Stop-Service sshd
sc.exe delete sshd 1> null
}
New-Service -Name sshd -BinaryPathName $sshdpath -Description "SSH Deamon" -StartupType Manual | Out-Null
Write-Host -ForegroundColor Green "sshd successfully installed"

View File

@ -0,0 +1,10 @@
if (Get-Service sshd -ErrorAction SilentlyContinue)
{
Stop-Service sshd
sc.exe delete sshd 1> null
Write-Host -ForegroundColor Green "sshd successfully uninstalled"
}
else {
Write-Host -ForegroundColor Yellow "sshd service is not installed"
}