Disclaimer: I’m still learning PowerShell. I’ve been using it more lately and I want to talk about it more. I’ll blog about the commands that I find useful.
Get-Member
Think of this command as the help button.
This is my current favorite command for troubleshooting an existing script. In PowerShell, you can “pipe” any object to this command and it will describe the properties and methods of that object.
Knowing the properties, you can then use Get-Member again to get the properties of those properties. That’s not confusing, right? Uhh, maybe a little. Let’s look at some examples.
I’m going to use the PowerShell ISE for this example. When you start PowerShell, it begins in the User directory.
Then I’ll run Get-ChildItem, which will get all the objects inside the current directory.
But what if I want to interact with those objects? I’ll need to know what their properties and methods are. That’s where Get-Member comes in!
Using the pipe to send the output to Get-Member
Simply send the output of any command to Get-Member.
Now we know all the details about that directory. Here’s the properties from further down the list, which shows some of the columns that were displayed when we ran Get-ChildItem.