The PowerShell Wiggum Loop
One of the best things about PowerShell is that you can interactively explore anything. Long before the Wiggum Loop was a thing, PowerShell let you explore interactively with prompting. Here's how you can embody the spirit of Ralph Wiggum and find your way around PowerShell.
All parts of the PowerShell Wiggum Loop are as old as PowerShell itself.
To be fair, the Simpsons did it first (1989).
PowerShell did it second (2006).
Generative AI came a lot later (~2020)
We used to call this many things that didn't imply you were an idiot. I'm calling this the "PowerShell Wiggum Loop" now only to make it easier to understand.
We used to call it:
The Trinity of Discoverability
Three commands help you find your way around PowerShell.
They are:
- Get-Command
- Get-Help
- Get-Member
Get-Command
PowerShell commands tend to be named with verb-noun pairs. Most people try to be as obvious as possible.
With that in mind, getting commands is pretty obviously named. To Get commands in PowerShell, you just run:
Get-CommandWe can get the syntax for a command with -Syntax
Get-Command Get-Command -Syntax
We can find all commands from a module with -Module.
Get-Command -Module Microsoft.*We can also get all commands of a -Verb. Let's get all the gets:
Get-Command -Verb GetWe can also look for nouns. Let's get all the -Module commands:
Get-Command -Noun ModuleAnd of course, we just search by wildcard:
Get-Command Get*Any non-script file is considered an Application. To see if ffmpeg is installed and in our path, we can use:
Get-Command ffmpeg* -CommandType ApplicationGet-Help
Continuing the obvious naming pattern, to get help we can:
Get-HelpThere are two types of help built into PowerShell: commands and topics.
Most topics are prefixed with about_. To see all of these "about" topics, we run:
Get-Help about_*Now let's get help about Get-Help
Get-Help Get-HelpAll commands should have help (it may not always be great help, but some help is better than none).
We can always work with help consistently. For example, if we wanted to get examples for Get-Help, it's just:
Get-Help Get-Help -ExamplesIf we wanted to see all of the parameter help, it's:
Get-Help Get-Help -Parameter *Get-Member
Last but not least, let's talk about objects.
PowerShell has a very flexible base object. You can dynamically add properties or methods to anything, or use any .NET class and enjoy all the functionality it has to offer.
The methods, properties, and events that make up an object are called it's "members".
So if we want to see the members of a bunch of objects, just pipe them to Get-Member:
Get-Command | Get-MemberThis shows us each method, property, and event available on each type of command object.
{"hello world"} | Get-Member{"hello world"}.Ast | Get-MemberConclusion
Long before the "Wiggum Loop" existed for AI, PowerShell has had it's own ways to simply FAFO with any object. Exploration is a key part of the language.
You may be much smarter than Ralph Wiggum, but you don't have to be a genius to find your way around PowerShell. Anyone can explore.
Have Fun!