.NET Daily

Turn On/Off Windows Services with PowerShell

Introduction

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.


LATEST POSTS

My View on the Life cycle of a Fixed Cost Web Project 01st July, 2018

How to Deliver Accurate Project Status Reports 21st April, 2018

Windows OS

Turn On/Off Windows Services with PowerShell

Posted on .

In today’s .NET Web application development landscape, having up and running all the plethora of services needed for development could seriously affect your notebook performance. In my case, having up the services for SQL Server, MongoDB, IIS plus at least two browsers for testing accounts for approx. 7 GB of RAM and 30% of CPU constant load.
Even if I don’t stay in front of my notebook, the cooler is constantly spinning making noise in the room.

So I looked for alternatives to easily turn on/off these services that I need for development in order not to have this constant load all the time.

And PowerShell scripts seems to be a good way to achieve this. At the bottom of the page you can download two PowerShell script which are turning on and off the services which I mentioned above.

Just as an info, the lines of code for turning a service off in PowerShell are the following:

$sqlServiceName = "SQL Server (SQLEXPRESS)"
Stop-Service $sqlServiceName
$serviceAfter = Get-Service $sqlServiceName
"$sqlServiceName is now " + $serviceAfter.status

And the lines for turning a service on are the following:

$sqlServiceName = "SQL Server (SQLEXPRESS)"
Start-Service $sqlServiceName
$serviceAfter = Get-Service $sqlServiceName
"$sqlServiceName is now " + $serviceAfter.status

These scripts can turn on or off pretty fast all the services that I need for development.

Hope can find them useful as well.

Attachments

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

There are no comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

View Comments (0) ...
Navigation