cmdlet - Powershell - Why some properties have related parameters -


i'm in process of learning powershell (v5 exact) , don't seem follow logic behind object properties , parameters.

if take:

get-service | gm 

we can see there "name" aliasproperty:

name                      aliasproperty name = servicename 

but (confusingly) have parameter called "-name" allows filtering on given name.

for example:

i can access name property doing:

(get-service).name 

and presumably filter piping it.

but can do

get-service -name "filter" 

my first question be, property related parameter? parameter given sort-of related helpful shortcut filtering on "name" property?

secondly, ask why there isn't corresponding parameter every property. example:

(get-service).servicetype 

doesn't have corresponding parameter:

get-service -servicetype 

thanks.

  1. no. parameters arguments accepted cmdlets. properties things belong object (input/output cmdlet)

  2. you can use where-object more selective based on property values, or select-object based on property names.


# filter based on servicetype get-service | where-object servicetype -eq win32shareprocess  # filter based on servicetype... return name get-service | where-object servicetype -eq win32shareprocess | select-object name 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -