Help in PowerShell for Office 365

 

Help and Get-Help

"Help" is listed as an alias for "Get-Help" but the results of running them are not the same. The easiest way to see this is to run the following commands.

>$a = help get-childitem

>$b = Get-Help get-childitem

>$a -is [array]

True

>$b -is [array]

False

>

The reason $a is an array is because "Help" produces a strings with line breaks or an array of strings. "Get-Help" produces a custom PowerShell object. You can access the various parts of the help object and manipulate the final output to be more useful. For example try the following:

 

>$b.syntax.syntaxitem[0].parameter | ft

 

This give you a list of the parameters in the first parameter set with all their properties. Many cmdlets contain multiple parameter sets and if they do you must use [#] to access the parameter set.

 

"Get-Help" is not all that helpful

If you have been using the PowerShell cmdlets in Office 365 you may have noticed something. The help files can often be a bit less than helpful.  The help files with the Module for administering the Office 365 service is fairly accurate it is just a bit sparse. Some of the commands lack any examples and many do not have related links or other information that would help understand exactly how to use the cmdlet.

The help files for the Exchange Online management session. All the cmdlets provided by the session are versions of cmdlets used to administer an Exchange Server. In producing help files for these cmdlet the help files were just copied from the original version of the cmdlet. The problem with this they are not identical. Most of the cmdlets have only a potion of the parameters available. This also makes many of the examples incorrect.

 

Quick Note

References to cmdlets refer to anything that the user see as a cmdlet such as functions and aliases.

 

Help for Office 365 Exchange cmdlets

To help resolve the issue of not knowing what parameters you have to use a handy tool is the Get-Command cmdlet. Get-Command access the actual properties of the cmdlet. You do need to do a little work to find the information though. The following two commands will provide a sorted list of parameters. I am using Get-Mailbox as my example cmdlet but it will work on any cmdlet

 

>$(Get-Command Get-Mailbox).parameters.keys | sort

 

The one drawback to this list is that it contains the common parameters that every cmdlet has and are usually not included in lists of parameters. To solve this you can filter them out. First you need a list of all the common variables in an array. PowerShell does not provide any short cut to this you just need to create your own.

 

>$Common = "Verbose", "Debug", "WarningAction", "WarningVariable", "ErrorAction", "ErrorVariable", "OutVariable", "OutBuffer", "WhatIf", "Confirm","AsJob"

 

Some will notice that I have included one parameter that is not listed usually as a common parameter. The parameter "AsJob" is used for functions running on remote systems. I have not yet explored its use but since all of the Exchange Online cmdlets are functions being run on a remote system they all have the option to run as jobs. That I think makes it a common parameter in this situation.

 

Next you use this new array to filter out all the common parameters.

 

>$(Get-Command Get-Mailbox).parameters.keys | Where {$Common -notcontains $_} | sort

 

Compare this to the output of the help file.

 

$(get-help get-mailbox).parameters.parameter | Foreach {$_.name}

 

The additional names you find in the help list are variables not available to you in Office 365. The variable that are missing from this list from the help file are part of other parameter lists.

 

This is just the tip of the iceberg but it is a start. It will be useful if you are trying to use a script that was designed for an Exchange Server. It is very possible that it uses parameters not available to you.