Skip to content

System.Diagnostics.Process shows a FileVersionInfo view that doesn't exist #15780

Closed

Description

Prerequisites

Steps to reproduce

Use master branch (or 7.2 preview 8 or newer where #14513 is available.

get-process | format-table -view <tab>

Not sure where it's picking up System.Diagnostics.FileVersionInfo as an option. If you choose it, you'll get an error:

Format-Table: The view name System.Diagnostics.FileVersionInfo cannot be found. Specify one of the following Table views and try again: process, Priority, StartTime.

Expected behavior

process                             StartTime
ProcessModule                       Priority                            ProcessWithUserName

Actual behavior

System.Diagnostics.FileVersionInfo  process                             StartTime
ProcessModule                       Priority                            ProcessWithUserName

Error details

Exception             :
    Type        : System.Management.Automation.PipelineStoppedException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : The pipeline has been stopped.
            HResult : -2146233087
        CategoryInfo          : OperationStopped: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : PipelineStopped
    TargetSite  :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace  :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord) in
/Users/steve/repos/PowerShell/src/System.Management.Automation/engine/MshCommandRuntime.cs:line 2086
    Message     : The pipeline has been stopped.
    Source      : System.Management.Automation
    HResult     : -2146233087
TargetObject          : System.Diagnostics.FileVersionInfo
CategoryInfo          : ObjectNotFound: (System.Diagnostics.FileVersionInfo:String) [Format-Table], PipelineStoppedException
FullyQualifiedErrorId : FormatViewNotFound,Microsoft.PowerShell.Commands.FormatTableCommand
ErrorDetails          : The view name System.Diagnostics.FileVersionInfo cannot be found. Specify one of the following Table views and try again: process, Priority, StartTime.
InvocationInfo        :
    MyCommand        : Format-Table
    ScriptLineNumber : 1
    OffsetInLine     : 15
    HistoryId        : 11
    Line             : get-process | format-table -View 'System.Diagnostics.FileVersionInfo'
    PositionMessage  : At line:1 char:15
                       + get-process | format-table -View 'System.Diagnostics.FileVersionInfo'
                       +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : format-table
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.7
PSEdition                      Core
GitCommitId                    7.2.0-preview.7-41-gb7d6ef2e506fb76e3c94abac2c59a17e48e17084
OS                             Darwin 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Activity

  1. added
    Needs-Triage
    on Jul 15, 2021
  2. SteveL-MSFT commented on Jul 15, 2021

    @SteveL-MSFT
    MemberAuthor

    So the reason FileVersionInfo shows up is that Get-Process can return those types when -FileVersionInfo is used, so this feature is working as expected, but there's an unfortunate side-effect of providing a view that may not be valid. I don't think there's anything we can do here.

  3. ghost removed
    Needs-Triage
    on Jul 15, 2021
  4. added
    Resolution-By Design
    on Jul 15, 2021
  5. iSazonov commented on Jul 15, 2021

    @iSazonov
    Collaborator

    Yes, it is a limitation. This works if we use a variable:

    $p = Get-Process
    $p | Format-Table -View <Tab>

    since we can do exact type inference.

    I don't think there's anything we can do here.

    We could enhance OutputType attribute to reflect parameter sets. Today we only add the metadata as a list:

    [OutputType(typeof(ProcessModule), typeof(FileVersionInfo), typeof(Process))]

    Proposal could be:

    [OutputType(ParameterSetName = NameParameterSet, typeof(FileVersionInfo))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-By Design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions