include noteproperty in output with select-object

Welcome Forums General PowerShell Q&A include noteproperty in output with select-object

Viewing 3 reply threads
  • Author
    Posts
    • #190051
      Participant
      Topics: 28
      Replies: 59
      Points: 154
      Rank: Participant

      https://powershell.org/forums/topic/include-noteproperty-in-output-with-select-object/

      $object | get-member says:

      displayname property
      id                     property
      [Microsoft.Windows.Computer].PrincipalName noteproperty

      how do i get to that principalname with a select-object or a where-object? these three are not doing it:

      $object | select [Microsoft.Windows.Computer].PrincipalName
      $object | select PrincipalName
      $object | select @{label='principalname';expression={$_.[Microsoft.Windows.Computer].PrincipalName} }

    • #190057
      Participant
      Topics: 1
      Replies: 1632
      Points: 3,074
      Helping Hand
      Rank: Community Hero

      You may show a little bit more of the code you're using to create the $object.

      And please format you code as code using the code tag button (pre). Thanks.

    • #190195
      Participant
      Topics: 0
      Replies: 21
      Points: 135
      Helping Hand
      Rank: Participant

      Select-Object doesn't know how to parse a property name like that. But you can use the object property access operator (.) to get the value.

      $object.'[Microsoft.Windows.Computer].PrincipalName'

      $object | select @{l='PrincipalName'; e={$_.'[Microsoft.Windows.Computer].PrincipalName'}}

       

    • #190402
      Participant
      Topics: 28
      Replies: 59
      Points: 154
      Rank: Participant

      thank you Sean. i was missing the single quotes around '[Microsoft.Windows.Computer].PrincipalName'.

       

Viewing 3 reply threads
  • You must be logged in to reply to this topic.