How to easily list all methods and properties of an object in Powershell

I don’t know about the RAM capacity in your head, but mine is kinda limited. Often time when I code in PowerShell, I don’t remember the exact name of a property/method. With the date and time object particularly. It’s different, yet very similar among the many programming languages I use daily.

so after I issue
$time=get-date

I usually fire up browser and go to Microsoft Technet PowerShell reference site to find the right command. I remember what it sounded like, but can’t remember exactly how to type it out. Yes you can type help get-date. But it doesn’t tell you all the properties and method you need.

if you want to know the list of all properties and method of an object/variable, set a value to a variable, and pass that variable to get-member cmdlet

$time=get-date
$time | get-member

You’ll get all the properties and method that belong to $time variable. A real time saver.


4 thoughts on “How to easily list all methods and properties of an object in Powershell

  1. At first I was going to make a snarky reply, but then I realized how old this post was. I just wanted to add in my own two cents though.

    I would have just run:
    Get-Member -InputObject Get-Date

  2. Thank you! This helped a bunch. I also discovered that you sometimes need to put double quotes around the cmdlet you want to get the members for, so that PowerShell doesn’t try to run the command.
    For instance, to get all the members for Foreach cmdlet, you have to enter:
    $variable=”foreach”
    $variable | Get-Member

Leave a Reply

Your email address will not be published. Required fields are marked *

*