In Need of some assistance with a script, working but I think it is missing a few things

Hello,

I’m trying to write a script that checks to see if a service exists, if it does, do nothing but if it doesn’t install the service. This is what I have so far and it installs the service but I’m not confident that my if statement is working.

$ErrorActionPreference = 'SilentlyContinue'

If ((Get-Service).Name -eq 'Test') {

} Else {

New-Service -Name Test -DisplayName "Reddit" -Description "Test" -BinaryPathName "C:Reddittest.exe" -StartupType Automatic | Start-Service

}

Any help is much appreciated. Thank you!

submitted by /u/adrzie
[link] [comments]

Leave a Reply