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: 29
      Replies: 59
      Points: 165
      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: 5
      Replies: 2368
      Points: 5,987
      Helping Hand
      Rank: Community MVP

      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: 24
      Points: 158
      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: 29
      Replies: 59
      Points: 165
      Rank: Participant

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

       

Viewing 3 reply threads
  • The topic ‘include noteproperty in output with select-object’ is closed to new replies.