2

I can fetch the Tag's key-value pair of a instance using powershell.

I have an object, $instance and $instance.Tags yields the following list:

Key                                     Value                                  
---                                     -----                                  
abc                                     cde
mnp                                     mju

How can I retrieve the value of any specific key?

Anthony Neace
  • 25,013
  • 7
  • 114
  • 129
Sumit Murari
  • 1,597
  • 3
  • 28
  • 43

2 Answers2

8

You can access by filtering on the key:

$instance.Tags | ? { $_.key -eq "mnp" } | select -expand Value
arco444
  • 22,002
  • 12
  • 63
  • 67
0
($instance.tags | ? $_.key -eq "mytag").value
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260
  • 1
    Could you please explain how this answer solves the OP's question. – Kingsley Dec 05 '18 at 01:00
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/21599048) – Abdul Waheed Dec 05 '18 at 05:47