- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get all properties and methods available for the service in PowerShell?
To display all the properties and methods available for the get-service cmdlet you need to pipeline Get-Member (alias gm). MemberType ‘Property’ is to display the specific property like machinename, servicename, etc. and with the MemberType ‘Method’ you can perform specific operations on the object, for example, Start, Stop, Pause the service, etc.
Command
The below command is to display all the members (properties, methods) the Get-Service.
Get-Service | Get-Member
Output
Name MemberType ---- ---------- Name AliasProperty RequiredServices AliasProperty Disposed Event Close Method Continue Method CreateObjRef Method Dispose Method Equals Method ExecuteCommand Method GetHashCode Method GetLifetimeService Method GetType Method InitializeLifetimeService Method Pause Method Refresh Method Start Method Stop Method WaitForStatus Method CanPauseAndContinue Property CanShutdown Property CanStop Property Container Property DependentServices Property DisplayName Property MachineName Property ServiceHandle Property ServiceName Property ServicesDependedOn Property ServiceType Property Site Property StartType Property Status Property ToString ScriptMethod
Command
To get the properties only.
Get-Service | Get-Member | where{$_.MemberType -eq "Property"}
Output
Name MemberType ---- ---------- CanPauseAndContinue Property CanShutdown Property CanStop Property Container Property DependentServices Property DisplayName Property MachineName Property ServiceHandle Property ServiceName Property ServicesDependedOn Property ServiceType Property Site Property StartType Property Status Property
Command
To get the methods only.
Output
Get-Service | Get-Member | where{$_.MemberType -eq "Method"}
Output
Name MemberType ---- ---------- Close Method Continue Method CreateObjRef Method Dispose Method Equals Method ExecuteCommand Method GetHashCode Method GetLifetimeService Method GetType Method InitializeLifetimeService Method Pause Method Refresh Method Start Method Stop Method WaitForStatus Method
Advertisements