PowerTip: Find Cmdlets that Need TimeSpan Object

PowerTip: Find Cmdlets that Need TimeSpan Object

  • Comments 3
  • Likes

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi
    The example above doesn't give any output!

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

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

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