My IT background contains no programming at all. I never even really wrote Batch scripts. I bring that up because I started learning PowerShell, and upon reading that it was object-oriented, my response was "neat." Not the appropriate response, which should have been "EVERYTHING IN MY LIFE IS WAY BETTER NOW!!"
Get-Member is a command that will let you know all you could ever want to know about the data you are collecting. Being object-oriented means you are not just getting a wall of text back, but structured data. Let's take a quick look at an example using Get-Member.
This object doesn't just contain the data but also has a list of methods that you can run against it. PowerShell will occasionally even throw in some script properties, which is the data with some extra PowerShell run against it. There is an excellent example of this in Get-Process. TotalProcessorTime is a timespan, which is not precisely how you might like that data. You can use the CPU scriptproperty, however, and it will break it down for you in total seconds. It is a built-in option to have usable information.
Finding Your Data Type
Get-Member will also let you know what your data type is. In our example, you can see that it is a system.diagnostics.process. A quick look at Stop-Process and we can see that it accepts that data type as an InputObject.
I know it seems obvious that something grabbed with Get-Process would work with Stop-Process. Knowing your data type becomes more important as we build our own functions. Let's take a quick look at a quick function.
Why Knowing Data Type is Important
Let's take a quick look at a quick function.
First, please excuse my lack of proper Verb-Noun pairing. Second, reading through this, you can see all this is doing is stopping a process, but we are still able to pipe in the process object and have it accepted. You have started down the path to automating as much as your job away as you can, there is a good chance that you will be building out functions. Understanding as much as you can about the data you are grabbing will make your automation that much more powerful.
This is Where the Conclusion Goes
If you are just getting started with PowerShell, this is one of the three commands that will give you all of the tools you need to accomplish what you are setting out to write.
That's it, what are you still here! Get out of here and start removing all the busy work from your life with the magic of PowerShell.
Jordan had spent his life wondering why tasks he didn’t like to do had no options to complete themselves. Eventually he had to make that happen on his own. It turned out that he enjoyed making tasks complete themselves, and PDQ thought that is something he should talk about on the internet while drinking most Thursdays on the PDQ webcast.