How do I show the properties of a Property?

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

This topic contains 5 replies, has 4 voices, and was last updated by

 
Participant
2 months, 3 weeks ago.

  • Author
    Posts
  • #162818

    Participant
    Topics: 115
    Replies: 244
    Points: 142
    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: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    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: 115
      Replies: 244
      Points: 142
      Rank: Participant

      thanks Olaf

  • #162891

    Participant
    Topics: 2
    Replies: 54
    Points: 278
    Helping Hand
    Rank: 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: 999
    Points: 1,946
    Helping Hand
    Rank: Community Hero

    One line :

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

     

    • #162975

      Participant
      Topics: 115
      Replies: 244
      Points: 142
      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

You must be logged in to reply to this topic.