Skip to content

Get-Command * doesn't always retrieve all properties #25738

@iRon7

Description

@iRon7

Prerequisites

Steps to reproduce

With a PowerShell module installed that contain PowerShell based cmdlets (functions).
E.g. the function Copy-ObjectGraph of the ObjectGraphTools module.
It appears that not all properties load when the commands are retrieved via a wide filter:

Steps to reproduce:

  • Open a new PowerShell session and run the following commands:
$CommandName = 'Copy-ObjectGraph'
$Command = Get-Command * | Where-Object Name -eq $CommandName
$Command.ScriptBlock

Expected to return the command's ScriptBlock but returns nothing
Yet, this is works fine:

$Command = Get-Command $CommandName
$Command.ScriptBlock

And now the first command set also appears to work...

Expected behavior

Expected to return the command's ScriptBlock

Actual behavior

Returns nothing

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions