PowerTip: Find Cmdlets that Need TimeSpan Object

Summary: Use Get-Command to find cmdlets that need a TimeSpan object for input.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find which cmdlets will accept a TimeSpan object for input?

Hey, Scripting Guy! Answer Use the ParameterType parameter from the Get-Command cmdlet, for example:

Get-Command -ParameterType timespan

Comments (3)

  1. Anonymous says:

    The example above doesn’t give any output!

    Shouldn’t it be
    get-command -parametername * -parametertype timespan
    get-command | where {$_.definition -match "-Timespan"}

  2. Anonymous says:

    I also tried it out on Windows 8.1 with PS 4.0
    Is functionality added by installed module / snapin?

  3. Ed Wilson says:

    @Andre the command works as written Get-Command -ParameterType timespan on my Windows 8.1 laptop with PowerShell 4.0.

Skip to main content