Windows Server 2016: Start Stop services using Powershell

Windows Server 2016: Start Stop services using Powershell

// -------------------------------------------

// Commands in Bold are on a single line

// -------------------------------------------

1) Windows Server > Powershell > PS C:\User\Administrator> Enter-PSSession - ComputerName 192.168.0.1 -Credential administrator

2) Enter:-  User Name: administrator | Password: xxxxxxxx (for the Windows Powershell credential request popup dialogue box).

// -------------------------------------------


// Get-service lists all (running & stopped) services

3) [192.168.0.1] PS C:\User\Administrator>Documents> Get-service

// -------------------------------------------

// Lists all services starting with the character d

4) [192.168.0.1] PS C:\User\Administrator>Documents> Get-service d*

// ------------------------------
 
// Displays the status of service:- docker

5) [192.168.0.1] PS C:\User\Administrator>Documents> Get-service docker

// ------------------------------
 
// Stops the service:- W32Time

6) [192.168.0.1] PS C:\User\Administrator>Documents> Stop-service w32time

// ------------------------------------------

// Start the service:- W32Time

7) [192.168.0.1] PS C:\User\Administrator>Documents> Start-service w32time

// ------------------------------------------

// Lists all services in which the Status states that it's running

8) [192.168.0.1] PS C:\User\Administrator>Documents> Get-service | where {$_.status -eq "running"}


// ------------------------------------------


// Lists all services in which the Status states that it's stopped

9) [192.168.0.1] PS C:\User\Administrator>Documents> Get-service | where {$_.status -eq "stopped"}

// ------------------------------------------

// Shows what would occur when services that are stopped are started
// ( Start-service ).

// WhatIf parameter allows you to see what your script or function would 
// have done if it were to have run.

10) [192.168.0.1] PS C:\User\Administrator>Documents> Get-service | where {$_.status -eq "stopped"} | Start-service -whatif

// ------------------------------------------




Comments