How do I show the properties of a Property?

Welcome Forums General PowerShell Q&A How do I show the properties of a Property?

Viewing 3 reply threads
  • Author
    Posts
    • #162818
      Participant
      Topics: 120
      Replies: 260
      Points: 238
      Rank: Participant

      I’m trying to put a script together and need to get at a property that is inside another property.

      Get-

      DnsServerResourceRecord -ZoneName contoso.com -ComputerName DNSServer -RRType txt -Name _dmarc |GM

      …and I see

      RecordData                Property   CimInstance#Instance RecordData {get;set;} 

      ..but I know there’s a Description field in there that I want to write to. How can I expose this and any other properties that are inside of the first level of a Property set?

      thanks

    • #162824
      Participant
      Topics: 5
      Replies: 2368
      Points: 5,987
      Helping Hand
      Rank: Community MVP

      I’m not able to test your particular cmdlet but usually you expand the content of a property with a Select-Object -ExpandProperty “Name Of The Property”.

      • #162972
        Participant
        Topics: 120
        Replies: 260
        Points: 238
        Rank: Participant

        thanks Olaf

    • #162891
      Senior Moderator
      Topics: 3
      Replies: 123
      Points: 653
      Helping Hand
      Rank: Major Contributor

      You can also do this:

      $foo = DnsServerResourceRecord -ZoneName contoso.com -ComputerName DNSServer -RRType txt -Name _dmarc
      $foo.RecordData | Get-Member
      

      or just

      $(DnsServerResourceRecord -ZoneName contoso.com -ComputerName DNSServer -RRType txt -Name _dmarc).RecordData | Get-Member
      
    • #162954
      Participant
      Topics: 2
      Replies: 1013
      Points: 2,093
      Helping Hand
      Rank: Community Hero

      One line :

      ((DnsServerResourceRecord -ZoneName $env:USERDNSDOMAIN -ComputerName ($(Get-ADDomainController).Name) -RRType 'A')[0]).RecordData | Get-Member

       

      • #162975
        Participant
        Topics: 120
        Replies: 260
        Points: 238
        Rank: Participant

        for some reason, this doesn’t return what I wanted but the above two posters did have the info I was seeking. Thanks

Viewing 3 reply threads
  • The topic ‘How do I show the properties of a Property?’ is closed to new replies.