Starting out with PowerShell can be confusing. Google helps. Code from PowerSploit, PoshSec, and others can help, but just following the project coding examples will eventually be confusing for new situations. Actually coding is the only way to get over the hump of understanding how to use PowerShell objects, comparisons, and loops. Even with experience, each situation is going to be different and confusing depending on the type of object, command let being used, and how the pipeline impacts the situation.
The following is an example of some information gathering I recently attempted. This will be a walk-thru of the steps I attempted before figuring out (with help from 3nc0d3r) actually worked in the end. For those readers that are familiar with PowerShell this will either be a “yeah, I went thru that” or a “oh, that was obvious” story. For the rest, this will be a series of commands that can be run to experience the output and frustration of dealing with PowerShell objects. The commands will be provided. It will be up to the reader to play along and determine the output. For those readers that don’t have time to play along, I will provide a brief description of the results. Play along for more details.