EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login
Home Data Science Data Science Tutorials PowerShell Tutorial PowerShell Get-Service
Secondary Sidebar
PowerShell Tutorial
  • cmdlet
    • PowerShell Wait
    • PowerShell Match
    • cmdlets in PowerShell
    • Start PowerShell from cmd
    • Add-Content in PowerShell
    • Get Help in PowerShell
    • PowerShell Copy-Item
    • PowerShell Remove-Item
    • PowerShell Move-Item
    • Get Command in PowerShell
    • PowerShell Run Command
    • Windows PowerShell ISE
    • Windows Powershell Commands
    • WinRM PowerShell
    • PowerShell Date
    • Powershell Write-Host
    • PowerShell Get-ChildItem
    • PowerShell Sort-Object
    • PowerShell Where Object
    • PowerShell Set-Content
    • PowerShell Set-Location
    • PowerShell Invoke-Command
    • PowerShell Invoke-Webrequest
    • PowerShell Get-Location
    • PowerShell Get-Date
    • PowerShell Get-Service
    • PowerShell Test-Path
    • Powershell Module Path
    • PowerShell Out-File
    • PowerShell if File Exists
    • Powershell Copy File
    • PowerShell Delete File
    • PowerShell New-Item
    • PowerShell Rename-Item
    • PowerShell ComputerName
    • PowerShell Get-Content
    • PowerShell Get-Item
    • PowerShell Get-ADUser
    • PowerShell Grep
    • PowerShell Concatenate String
    • PowerShell Get-Process
    • PowerShell Count
    • PowerShell pause
  • Basics
    • PowerShell Restart Service
    • PowerShell comment
    • PowerShell Map Network Drive
    • PowerShell Append to File
    • PowerShell print
    • What is PowerShell
    • Uses Of Powershell
    • PowerShell Empire
    • PowerShell Parameter
    • PowerShell Stop Service
    • PowerShell Versions
    • How To Install PowerShell
    • PowerShell uninstall module
    • How to Use PowerShell?
    • PowerShell Logging
    • PowerShell Tools
    • PowerShell Commands
    • PowerShell Version Command
    • PowerShell Administrator
    • PowerShell Modules
    • PowerShell Registry
    • PowerShell block Comment
    • PowerShell Verbs
    • PowerShell list
    • PowerShell add user to group
    • PowerShell Write to Console
    • Variable in PowerShell
    • PowerShell New Line
    • PowerShell prompt for input
    • PowerShell File Extension
    • Powershell Remotesigned
    • PowerShell Write to File
    • PowerShell Ping
    • PowerShell wget
    • PowerShell Global variable
    • PowerShell Get-ADGroup
    • Array in PowerShell
    • PowerShell Multidimensional Array
    • PowerShell Array of Strings
    • PowerShell? join array
    • Useful PowerShell Scripts
    • String in PowerShell
    • PowerShell Switch Statement
    • PowerShell Function Parameters
    • PowerShell vs PowerShell ISE
    • PowerShell test-connection
    • PowerShell Test-NetConnection
    • PowerShell GUI
    • PowerShell Variable in String
    • PowerShell Active Directory
  • Variables
    • PowerShell Variables
    • PowerShell Environment Variables
    • PowerShell set environment variable
    • Hashtable in PowerShell
    • Set Variable in PowerShell
  • Operators
    • PowerShell Operators
    • Comparison Operators in PowerShell
    • Logical Operators in PowerShell
    • PowerShell Boolean
    • PowerShell Like Operator
  • Control Statements
    • If Statement in PowerShell
    • If Else in PowerShell
    • Else If in PowerShell
    • Loops in PowerShell
    • For loop in PowerShell
    • PowerShell While Loop
    • PowerShell do while
    • PowerShell Loop through Array
    • PowerShell add to array
    • PowerShell ForEach Loop
    • PowerShell Break
    • PowerShell Continue
    • Switch Case in PowerShell
    • PowerShell If-Not
    • Try-catch in PowerShell
  • Functions
    • PowerShell Functions
    • PowerShell String Functions
    • powershell nslookup
    • PowerShell here string
    • PowerShell Wildcards
    • Regex in PowerShell
    • PowerShell not like
    • PowerShell Filter
    • PowerShell Sleep
    • PowerShell where
    • PowerShell join string
    • PowerShell Exit
    • PowerShell null
    • PowerShell Dictionary
    • PowerShell Location
    • PowerShell Start-Service
    • PowerShell is not digitally signed
    • PowerShell Uptime
    • PowerShell Create Directory
    • PowerShell Trim
    • PowerShell Join-Path
    • PowerShell Execution Policy
    • PowerShell SubString
    • PowerShell Format Table
    • PowerShell Import Module
    • PowerShell ForEach Object
    • PowerShell Alias
    • PowerShell Scheduled Task
    • PowerShell Convert String to Date
    • PowerShell Split String
    • PowerShell Multiline String
    • PowerShell MultiLine Comment
    • PowerShell Rename Folder
    • PowerShell Delete Folder
    • PowerShell String Replace
    • PowerShell join
    • PowerShell xcopy
    • PowerShell Base64
    • PowerShell Tail
    • PowerShell User List
    • PowerShell remove User from group
    • PowerShell JSON Format
    • PowerShell Send Mail
    • PowerShell Convert to String
    • PowerShell Start-Process
    • PowerShell change directory
    • PowerShell Open File
    • PowerShell Batch File
    • PowerShell ZIP
    • PowerShell unzip
    • PowerShell XML
    • PowerShell XML Parsing
    • Remote PowerShell
    • PowerShell Escape Character
    • PowerShell scriptblock
    • PowerShell Executable Location
    • PowerShell Import-CSV?
    • PowerShell Export CSV
  • Interview Questions
    • PowerShell Interview Questions

Related Courses

Shell Scripting Course

All in One Data Science Courses

Data Visualization Courses

PowerShell Get-Service

By Chirag NagarekarChirag Nagarekar

PowerShell Get-Service

Introduction to PowerShell Get-Service

Get-Service cmdlet in PowerShell is used for retrieving the services (Operating systems and applications) installed on the local computer and the remote computers as well along with their Start type, status, name and display name of the services. PowerShell console will display all the services which are present in the Services.msc MMC.  By default Get-Service cmdlet provides the information about local computer services until the –ComputerName parameter specified for the remote computers. We can also retrieve the dependent services with this cmdlet. This cmdlet is part of the Microsoft.PowerShell.Management module.

Syntax

Get-Service
[[-Name] <String[]>] [[-DisplayName] <String[]>
[-DependentServices] [-RequiredServices] [-Include <String[]>] [-Exclude <String[]>] [-InputObject <ServiceController[]>] [<CommonParameters>]

Parameters

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Below are the parameters:

  • Name: This parameter is for the name or alias name of the service. It is a string object. You can provide multiple services names (aliases) separated by comma (,). Wildcard character (*) is permitted. For example, the spooler is the alias name of the “Print Spooler” service.
  • DisplayName: This parameter is for the display name of the service. It is a string datatype. You can provide multiple display names separated by comma (,). Wildcard character (*) is permitted. For example, “Windows Management Instrument” is the display name of the winmgmt service alias.
  • DependentServices: When this parameter is specified, it retrieves the dependent services of the provided service name. This parameter must be used with the –Name or the –DisplayName parameter, otherwise, PowerShell will retrieve all the dependent services.
  • RequiredServices: This parameter specifies the services which are required to start the given service(s). You must specify the –Name or –DisplayName parameter, otherwise, PowerShell will retrieve all the required services.
  • Include: This parameter specifies the service name to include while retrieving the Service information. The value of this parameter qualifies the Name You can use the wildcard character (*). For example, When you specify S*, it will retrieve all the services that start with the S.
  • Exclude: This parameter specifies the service name to exclude while retrieving the set of services information. The value of this parameter qualifies the Name You can use the wildcard character (*). For example, when you specify S*, it will retrieve all the services excluding services starting with S*.
  • InputObject: You can provide multiple services as a variable to the input object parameter to retrieve the services from Get-Service cmdlet.
  • CommonParameters: These parameters are for the error and warning handling, debug, verbose, etc.. parameters. For example, -ErrorAction, -ErrorVariable, -WarningVariable, -WarningAction, -Verbose, -Debug, -OutBuffer, -OutVariable.

Examples to Implement PowerShell Get-Service

Below are examples to implement:

1. Get-Service with the – Name Parameter

When you don’t specify any parameter with Get-Service cmdlet, it default takes the –Name parameter. To retrieve the service information with the –Name parameter, we need to provide the valid service name. The default output will be Status, Name and DisplayName format.

Code #1

Get-Service -Name Winmgmt

All in One Data Science Bundle(360+ Courses, 50+ projects)
Python TutorialMachine LearningAWSArtificial Intelligence
TableauR ProgrammingPowerBIDeep Learning
Price
View Courses
360+ Online Courses | 50+ projects | 1500+ Hours | Verifiable Certificates | Lifetime Access
4.7 (86,584 ratings)

Output:

Name ParameterPowerShell Get-Service - 1

Explanation: You can also use the wildcard to retrieve the information.

Code #2

Get-Service -Name Win*

Here, Get-Service will retrieve all the services starting with the “Win”.

Output:

Name Parameter

Explanation: You can get the multiple services information with the –Name parameter by separating them with a comma (,).

Code #3

Get-Service -Name Winmgmt, WinRM, Spooler

Output:

Name Parameter

2. Get-Service with the – DisplayName parameter

You can provide the displayname parameter to the Get-Service cmdlet to retrieve services information.

Code #1

Get-Service -DisplayName "Print Spooler"

Output:

DisplayName parameter

To use the wildcard character (*),

Code #2

Get-Service -DisplayName "*Spooler*"

Output:

DisplayName parameter

3. Get-Service with the – DependedService

To get the depended services information of the particular service, use the below command.

Code #1

Get-Service Winmgmt -DependentServices

Output:

DependedService

Explanation: In the above output, the Windows management instrument service is dependent on the given services in the output.

This parameter also works with the Display name and the Wildcard character and even for the multiple services.

Code #2

Get-Service -DisplayName "Windows Management Instrumentation" -DependentServices

Output:

DependedService

Explanation: You can check the same in the Services property in the “depends on” the section from the Services.msc console.

DependedService

4. Get-Service with the – RequiredService

With this parameter, you will get the required services information (particular service which depends on the other services).

Code #1

Get-Service Winmgmt -RequiredServices

Output:

RequiredService

Explanation: The above output mentions that the RPCSS service is required for Winmgmt service. Meaning that Winmgmt service is in the dependent list of the RPCSS service. You can check the same in the service property.

Output:

PowerShell Get-Service - 10

5. Get-Service with the – Include Parameter

When you use the include parameter, it searches for the content mentioned after include parameter.  Wildcard character (*) is accepted. For example,

Code #1

Get-Service -Include S*, *print*

Output:

PowerShell Get-Service - 11

Explanation: The above command will include all the services that start with S and contain Print in the service name. you can retrieve the same output with the Name parameter as well.

6. Get-Service with the – Exclude parameter

With the exclude parameter, service names are excluded and the rest of the services will be displayed.

Code #1

Get-Service -Exclude S*, A*, *Windows*

Explanation: The above command excludes services starting with S, A and which contain Windows in the output command.

Output:

PowerShell Get-Service - 12

Explanation: You can only qualify search for the Name parameter but not for the others like DisplayName, Start type, etc.

7. Get-Service with the Format-List

Get-Service cmdlet provides the default output, which contains only a few table items like Display Name, Name, and status but if you want to display all the properties then pipeline the Format-List * (fl *) alias.

Code #1

Get-Service Spooler | Format-List *

Output:

PowerShell Get-Service - 13

8. Get-Service with the Select-Object Pipeline

You can retrieve the selected properties with the Select-Object (alias: Select) parameter.

Code #1

Get-Service winmgmt, winrm | Select Name, DisplayName, Starttype, Status

Output:

PowerShell Get-Service - 14

Conclusion

With the Get-Service you can retrieve the service information on the local computer and the remote computers, but you can also pipeline Start-Service and Stop-Service to Start or stop the services on local and remote computers.

Recommended Articles

This is a guide to PowerShell Get-Service. Here we discuss Syntax, parameters and top 8 examples to implement with proper codes and outputs. You can also go through our other related articles to learn more –

  1. PowerShell Get-Process
  2. PowerShell Get-Item
  3. PowerShell Get-Content
  4. PowerShell Grep
Popular Course in this category
PowerShell Training (2 Courses, 1 Project)
  2 Online Courses |  1 Hands-on Project |   4+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Shell Scripting Training (4 Courses, 1 Project)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
Data Visualization Training (15 Courses, 5+ Projects)4.7
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Data Science Course

SPSS, Data visualization with Python, Matplotlib Library, Seaborn Package

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more