Pulling specific info from Properties when it is a hashtable RRS feed

  • Question

  • I'm using the Get-AzureRmResource cmdlet, and for the output I'm selecting only Name and Properties because properties contains creationTime which is what I'm after.  How do I pull only the creationTime and omit everything else?  

    I tried select-object Name, Properties.creationDate but that does not work.  Instead I get all the information in the Properties hashtable.  My goal here is once I can isolate the creationDate, to then convert it to something more readable.

    Thanks for your help!

    Name                                   Properties
    ----                                   ----------
    VMImage1                       @{vhd=; description=slim; author=; creationDate=2017-12-12T20:21:28.9685824+00:00;}
    VMImage2                     @{vhd=; description=long; author=; creationDate=2017-12-12T20:40:03.2183175+00:00;}

    Wednesday, December 13, 2017 4:39 PM


  • Try:

    select -expand properties | select name,value


    Wednesday, December 13, 2017 11:10 PM

All replies

  • Maybe try

    Select-Object Name, @{Name='Creation Date';Expression={$_.Properties["CreationDate"]}}

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Wednesday, December 13, 2017 5:28 PM
  • Thank you for your response and help! I tried using it, but the Creation Date column in the output is blank. I'll keep trying different variations.  
    Wednesday, December 13, 2017 10:47 PM
  • Try:

    select -expand properties | select name,value


    Wednesday, December 13, 2017 11:10 PM
  • This worked.  Thank you!  Using -ExpandProperty on Select broke down the Properties hashtable so I could then call things out inside of it.  It ended up looking like this:

    select -ExpandProperty properties | select Name, creationDate

    Wednesday, December 13, 2017 11:30 PM