How to use PowerShell Get-Member cmdlet

后端 未结 4 459
[愿得一人]
[愿得一人] 2020-12-15 22:52

A newbie question:

The command:

[Math] | Get-Member

Returns all members of System.RuntimeType. Why is that?

Al

4条回答
  •  攒了一身酷
    2020-12-15 23:15

    Also, does Get-member takes any positional parameters? How can I tell?

    If the parameter name is wrapped in '[]' then the name is optional, so the parameter is positional. For example for Get-Member (definition below), Name is positional but InputObject is not.

    Get-Member [[-Name] ] [-Force] [-InputObject ] [-MemberType {AliasProperty | CodeProperty | Pro perty | NoteProperty | ScriptProperty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Methods | P arameterizedProperty | MemberSet | Event | All}] [-Static] [-View {Extended | Adapted | Base | All}] []

    For the 1st 2 questions, it seems like you expect them to behave like objects but you are entering a namespace/class. If you do "1 | gm" or "gm -inputobject 1" you will see more like what you want/expect.

提交回复
热议问题