Creating and deleting a Windows Service with Sc.exe

Someone was trying to manually install a windows service earlier this week and I found an old document I had written a year or so ago with instructions on how I did this before using SC.exe.  I thought i’d post it on here for future reference.

Installing a service
sc create "My Service name" binPath= "c:\MY_FOLDER\MyService.exe"
Deleting a service
sc delete "My Service name"
Querying a service
sc query "My Service name"

PowerShell scripts to remotely manage IIS

I was getting tired of opening a Remote Desktop Connection to our development environment web server to stop, start or restart IIS after making a configuration change so I found out how to do this remotely using PowerShell.  Thought I’d post the scripts on here so I can reference them in the future and also so others can make use of them.

Restart IIS
invoke-command -computername [INSERT_COMPUTER_NAME] -scriptblock {iisreset}
Stop IIS
invoke-command -computername [INSERT_COMPUTER_NAME] -scriptblock {iisreset /STOP}
Start IIS
invoke-command -computername [INSERT_COMPUTER_NAME] -scriptblock {iisreset /START}