Finding Cmdlets with Dynamic Parameters

by Aug 3, 2015

Some cmdlets expose dynamic parameters. They are valid only in certain contexts. Get-ChildItem, for example, exposes -File and -Directory only when the current location is a file system path (and you are at least running PowerShell 3.0).

To find all cmdlets that have dynamic parameters, try this:

#requires -Version 2

$cmdlets = Get-Command -CommandType Cmdlet


$loaded = $cmdlets |
Where-Object { $_.ImplementingType } 


$dynamic = $loaded | 
Where-Object { 
    $cmdlet = New-Object -TypeName $_.ImplementingType.FullName
    $cmdlet -is [System.Management.Automation.IDynamicParameters] 

$dynamic | Out-GridView 

You will get back only loaded cmdlets, and only those that have dynamic parameters.

Twitter This Tip! ReTweet this Tip!