Finding all parameters

I’ve tested powershell v3 ctp2 and beta and noticed that the following command provided by this tips page still fails:

Get-Command -CommandType Cmdlet | Select-Object -ExpandProperty Parameters |  ForEach-Object { $_.Keys } | Group-Object -NoElement | Sort-Object Count, Name -Descending

get-command bug

Joel Bennett explained in his blog post why it fails. To make it short, it’s due to the fact that modules are preloaded (new feature in powershell 3) when you invoke cmdlets but not when you use the Get-command cmdlet.

The above command won’t fail if all modules are loaded. Here’s how to load all modules

Get-Module -ListAvailable | % { ipmo -Name $_.Name}

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.