4 Tips for Using Get-Help in PowerCLI/PowerShell

Hey EveryOne! vNoob Back to hopefully drop a couple of knowledge bombs on you.

Powershell/PowerCLI is really good at giving you the information you ask for…however, it isn’t always easy to know what to ask or how to ask. Hopefully these tips will help you get more of the information you want from Powershell/PowerCLI.

1. Use it like google

Well alright, maybe not just like google, but most don’t utilize search in get-help the way that they should. When you do a search get-help, it not only searches the cmdlet names but also the ENTIRE HELP FILE. This means that you don’t always need to know what cmdlet you are looking for.

As an example. Let’s say I want to find which cmdlet to use that would change how many CPUs are assigned to a VM….

Alright that is a bit longer of a list than I was hoping for….or is it?

If we look at only the ones whose module starts with VMware

This is a much smaller list, and hopefully it becomes apparent which cmdlet we want. As a reminder we are looking for the cmdlet which will SET the VM   number of CPUs 🙂

2. Brackets Brackets Brackets

This is a tip that takes a bit of practice to remember, and I even have to look it up sometimes.

Let’s look at the get-help for Set-VM

Looking at the syntax, there are a LOT of Brackets. But what do they all mean?

The first parameter is [-VM]  <VirtualMachine[]>

  • When Square Brackets just enclose the parameter name and not also it’s data type. This means that -VM is a mandatory parameter.
  • This is different from [-Name <String>], in which everything is enclosed in squarebrackets, making it an optional parameter
  • DataTypes are enclosed in <>
  • An empty square bracket [] at the end of a DataType means that parameter can accept arrays as input, example [-VM]  <VirtualMachine[]>
  • Anything enclosed in square brackets, and does Not have a DataType is a common parameter, do a “get-help about_commonparameters” for more info on those

3. Use Get-Help Parameters

Directly from using get-help of get-help, here are what I think some of the most useful parameters are
-Detailed [<SwitchParameter>]
Adds parameter descriptions and examples to the basic help display.    This parameter is effective only when help files are for the command are installed on the computer. It has no    effect on displays of conceptual (“About_”) help.
-Examples [<SwitchParameter>]
Displays only the name, synopsis, and examples. To display only the examples, type “(Get-Help    <cmdlet-name>).Examples”.    This parameter is effective only when help files are for the command are installed on the computer. It has no    effect on displays of conceptual (“About_”) help.
-Full [<SwitchParameter>]

Displays the entire help topic for a cmdlet, including parameter descriptions and attributes, examples, input    and output object types, and additional notes.    This parameter is effective only when help files are for the command are installed on the computer. It has no    effect on displays of conceptual (“About_”) help.

-ShowWindow [<SwitchParameter>]
Displays the help topic in  a window for easier reading. The window includes a “Find” search feature and a “Settings” box that lets you set options for the display, including options to display only selected section of a help topic. The ShowWindow parameter is valid for all types of help topics, including help topics for cmdlets, functions, and providers and conceptual “About” topics.
4. Help not Get-Help

Using Help instead of Get-Help two pretty awesome things

1. It’s shorter to type

2. It essentiall runs “Get-Help  | more”

This means that running  “help set-vm” will actually paginate the returned information, making it much easier to comsume and look through. To say it another way, this will only display one page of the help at a time instead of giving you all the pages streaming through the powershell/powercli window at once.

This is especially helpful when using the -full parameter 🙂

 

I hope this helps and takes some mystery away from using Get-Help!

 

One thought on “4 Tips for Using Get-Help in PowerCLI/PowerShell”

Comments are closed.