Tab completion for PSCustomObject

Welcome Forums General PowerShell Q&A Tab completion for PSCustomObject

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
  • #5839

    Points: 0
    Rank: Member

    by stromnessian at 2013-04-23 13:10:22


    I'm sure there must be a good reason for this, but why, when I try to create a custom object in v3.0 by starting the command:

    $obj = [pscust

    then try to TAB complete, it completes as [psobject] and when I add a hash table with the desired properties, the resultant object is a hash table? If I want a PSCustomObject, it seems I have to complete the full type name. (Sorry, being picky here, but I don't like typing!!)

    Many thanks

    by poshoholic at 2013-04-23 21:02:34

    That seems like a bug due to how tab completion works in PowerShell and due to the fact that the [pscustomobject] type is actually a special-case [psobject] that PowerShell's interpreter treats differently.

    You can see why tab completion is doing what it does by invoking this command:
    Compare that to:
    That illustrates that [pscustomobject] is actually [psobject]. It provides for a little bit of syntactic magic when it comes to object creation with hash tables.

    If it's a bug that you really want to see fixed, you should open a bug report on Microsoft Connect and encourage others to vote it up.

    by stromnessian at 2013-04-24 00:23:12

    Thanks, Kirk.

The topic ‘Tab completion for PSCustomObject’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort