Ok… I was playing. I’ll admit it.
When you do GET-HELP on some cmdlets, especially ones with a LARGE abundance of available parameters, they might appear a little daunting.
I used to do a little trick by copying the output under “SYNTAX” on the GET-HELP. I would then paste it into my favorite Word processor (Microsoft Word 2010 naturally) and do two quick Search/Replace operations to pull the lines together and then split based upon the display of the brackets “” in the display.
That little trick would give me a nice viewable and easy to understand list of the parameters available.
I am now more comfortable with sticking my fingers under the hood (and not getting burned or snipped by spinning Radiator fans) with Powershell and decided there HAD to (I mean with a big giant Heaping CAPITAL H) HAD TO be a Powershell way.
I played with the properties exposed from GET-HELP. I made the incorrect presumption the output was string. Then I forgot Rule 1 in Powershell.
“All output is an Object”
Turned out the Object in question had some interesting properties available, namely one called “SYNTAX”. On a whim, I wondered if the Syntax NoteProperty was the “How to use Powershell Syntax” from GET-HELP. So I popped it open
“Jumpin’ June Bugs!” I screamed out. It was! So again another “GET-MEMBER” to see what this might yield.
(GET-HELP GET-QADUSER).Syntax | GET-MEMBER
“SyntaxItem” now…. but it was a NoteProperty. I wanted to see just what it would expose. So a quick “SELECT-OBJECT” out of my sleeve later
(GET-HELP GET-QADUSER).Syntax | SELECT-OBJECT –ExpandProperty SyntaxItem
“AHA! There’s the tricky fellow hiding inside!” So another piece to open up with SELECT-OBJECT…
(GET-HELP GET-QADUSER).Syntax | SELECT-OBJECT –ExpandProperty SyntaxItem | SELECT-OBJECT –ExpandProperty parameter
WHOOOOOOSH!!! The screen filled with the familiar “Detailed” data from help. But again, I learned … run a GET-MEMBER to see what the object is exposing….
(GET-HELP GET-QADUSER).Syntax | SELECT-OBJECT –ExpandProperty SyntaxItem | SELECT-OBJECT –ExpandProperty parameter | GET-MEMBER
I took a shot that “Name” might be the parameter name, so yet one more SELECT-OBJECT and the fingers crossed…
(GET-HELP GET-QADUSER).Syntax | SELECT-OBJECT –ExpandProperty SyntaxItem | SELECT-OBJECT –ExpandProperty parameter | SELECT-OBJECT name
JACKPOT! I had it! An easier way to view the names! Now to make this into something useful! A regular script to pull the data out. The only parameter I was really supplying would be the results of a GET-HELP on any Cmdlet I had.
——– Begin Script ——–
($HelpData).Syntax | SELECT-OBJECT –ExpandProperty SyntaxItem | SELECT-OBJECT –ExpandProperty parameter | SELECT-OBJECT name
——- EndScript ——-
So most of the time I’m ok reading with a GET-HELP, but now for those cmdlets with more parameters than I can imagine, I can at least get them out in a nice clean list to see what I can work with. Now to find out all I have to do is run my script like so
./LISTPARAMETERS.PS1 –HelpData (GET-HELP GET-CHILDITEM)
To get all the parameters in a nice list from GET-CHILDITEM. I’m thinking this should make working with the WPF stuff a little easier. Now those, THOSE have some parameters
Remember, the Power of Shell is in YOU
The Energized Tech