Tuesday, March 12, 2013

Restarting a service on a remote machine

If you have Windows Servers that you need to do any admin on, you should already have set them up with powershell and enable remoting.

If you need to restart a service from your own box, do not be a monkey and RDP into the machine and go to control panel, etc.

Open powershell on your own machine and type this:

icm SERVERNAME { net stop 'Service Name'; net start 'Service Name'; }

If you find yourself doing this a lot, open up your profile script at "~/Documents/WindowsPowerShell/Microsoft.PowerShell_profile.ps1"  (If it doesn't exist, make it) and define this as a function that you can easily remember:

function restart-jira() { icm SERVERNAME {  net stop 'Atlassian JIRA'; net start 'Atlassian JIRA'; }

Restart your shell (or reload profile script) and from now on you can just type e.g. "restart-jira" and it will restart the remote service.


No comments: