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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -