Monday, August 11, 2014

Windows Server 2012: Start / Stop Services With PowerShell

How can someone start or stop Windows Services with PowerShell? In my case I needed to start / stop SharePoint 2010 / 2013 Services.

To stop services use something on the line of this:

With $services I just create a simple array, which I will use in my foreach. Stop-Service simply stops the service I want to stop. I will also pause the script with .WaitForStatus() until the service reached a certain status, which is "Stopped" in this example.

To start services, it's the same, except that the status changed:

Edit 08/13/14: Had to update the scripts.

No comments:

Post a Comment