jdhitsolutions / PSScriptTools

:wrench: :hammer: A set of PowerShell functions you might use to enhance your own functions and scripts or to facilitate working in the console. Most should work in both Windows PowerShell and PowerShell 7, even cross-platform. Any operating system limitations should be handled on a per command basis. The Samples folder contains demonstration script files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get-ParameterInfo on commands with -Count Parameters Errors

ninmonkey opened this issue · comments

Describe the bug

Get-ParameterInfo on any command with a -count parameter triggers an exception:

Cannot compare "System.Management.Automation.ParameterMetadata" because it is not IComparable.

To Reproduce

Get-Command 'Get-Random' | Get-ParameterInfo

PS> Get-Command Get-Random | Get-ParameterInfo
InvalidOperation: C:\Users\...\PSScriptTools\2.38.0\functions\Get-Parameter.ps1:58
Line |
  58 |          if ($data.count -gt 0) {
     |              ~~~~~~~~~~~~~~~~~
     | Cannot compare "System.Management.Automation.ParameterMetadata" because it is not IComparable.

Expected behavior

Not throw when elements have the parameter.

Environment

Windows10

PS> $PSVersionTable | Select-Object -prop PSVersion, GitCommitId, OS, PSEdition

PSVersion GitCommitId OS                           PSEdition
--------- ----------- --                           ---------
7.1.4     7.1.4       Microsoft Windows 10.0.19043 Core


PS> Get-Module PSScriptTools

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     2.38.0                PSScriptTools