PowerShell Get-Service Cmdlet
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed Resolve-Path cmdlet in PowerShell.
https://cloudaffaire.com/powershell-resolve-path-cmdlet/
In this blog post, we will discuss Get-Service cmdlet in PowerShell. You can use Get-Service cmdlet to get windows service status. Get-Service cmdlet returns the service status whether its running or stopped along with other details like service name, service display name, dependent service, etc. You can use Get-Member cmdlet to get all the list of items that you can get using Get-Service cmdlet. You need to permission to view windows service status to use Get-Service cmdlet. Get-Service cmdlet can also be used to get the service status of a remote computer using ‘ComputerName’ parameter.
Get-Service Cmdlet Syntax:
1 2 3 4 5 6 7 8 9 |
## Get-Service ## [[-Name] ## [-ComputerName ## [-DependentServices] ## [-RequiredServices] ## [-Include ## [-Exclude ## [-InputObject ## [ |
Get-Service Cmdlet Argument List:
- –ComputerName: Gets the services running on the specified computers. The default is the local computer.
- –DependentServices: Indicates that this cmdlet gets only the services that depend upon the specified service.
- –DisplayName: Specifies, as a string array, the display names of services to be retrieved. Wildcards are permitted.
- –Exclude: Specifies, as a string array, a service or services that this cmdlet excludes from the operation.
- –Include: Specifies, as a string array, a service or services that this cmdlet includes in the operation.
- –InputObject: Specifies ServiceController objects representing the services to be retrieved.
- –Name: Specifies the service names of services to be retrieved. Wildcards are permitted.
- –RequiredServices: Indicates that this cmdlet gets only the services that this service requires.
PowerShell Get-Service Cmdlet:
Get All The Columns And Functions Available To Get-Service Cmdlet:
1 2 3 4 5 6 7 8 |
####################################### ## PowerShell | Cmdlet | Get-Service ## ####################################### ## PowerShell Latest Version (5) ## get all members of Get-Service cmdlet Get-Service | Get-Member |
Get All Windows Service Status In PowerShell:
1 2 3 |
## get all windows service status in PowerShell Get-Service |
Get A Specific Windows Service Status In PowerShell:
1 2 3 |
## get a specific windows service status in PowerShell Get-Service -Name "Winmgmt" |
Get The Complete Details For A Windows Service In PowerShell:
1 2 3 |
## get the details for a windows service in PowerShell Get-Service -Name "Winmgmt" | Select-Object * | Format-List |
Get A Specific Windows Service Status By Its Display Name In PowerShell:
1 2 3 |
## get windows service status by its display name Get-Service -DisplayName "Windows Management Instrumentation" |
Get All The Dependent Services For A Windows Service In PowerShell:
1 2 3 |
## get all the dependent services for a windows service in PowerShell Get-Service -Name "Winmgmt" -DependentServices |
Get All The Required Services For A Windows Service In PowerShell:
1 2 3 |
## get all the required services for a windows service in PowerShell Get-Service -Name "Winmgmt" -RequiredServices |
Get Windows Service Status For Remote Computers In PowerShell:
1 2 3 |
## get windows service status for remote computers Get-Service -Name "Winmgmt" -ComputerName "Computer1" "Computer2" |
Get Windows Service Status By Wildcard Entry In PowerShell:
1 2 3 |
## get windows service status using wildcard entry Get-Service -DisplayName "Windows*" |
Get All The Running Windows Services In PowerShell:
1 2 3 |
## get all the running windows services list using PowerShell Get-Service | Where-Object { $_.Status -eq "Running"} |
Get All The Stopped Windows Services In PowerShell:
1 2 3 |
## get all the stopped windows services list using PowerShell Get-Service | Where-Object { $_.Status -eq "Stopped"} |
Get The Start-up Mode For A Windows Service In PowerShell:
1 2 3 4 5 |
## get a windows service start-up mode in PowerShell Get-Service -Name "Winmgmt" | Select-Object StartType Get-WmiObject -Class Win32_Service -Property StartMode -Filter "Name='Winmgmt'" |
Hope you have enjoyed this article. In the next blog post, we will discuss Set-Service cmdlet in PowerShell.
To Set more details on PowerShell, kindly follow below official documentation