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.
no. parameters arguments accepted cmdlets. properties things belong object (input/output cmdlet)
you can use
where-object
more selective based on property values, orselect-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
Post a Comment