Filter Specific value within ValueCollection

Nandan Hegde 36,886 Reputation points MVP Volunteer Moderator
2022-09-05T07:38:28.22+00:00

Hello All,

I have a variable in PowerShell with the below type
237738-image.png

Attached is the output value of that variable
237725-lsapi.txt

Now the need is to get the referencename within Next value wherever it is available .

How can one filter those specific values

@Rich Matheisen

237726-image.png

Windows for business | Windows Server | User experience | PowerShell

2 answers

Sort by: Most helpful
  1. Peter Holpar 6 Reputation points
    2026-07-23T10:49:27.47+00:00

    Try
    $yourVariable.Keys | % { $yourVariable[$_]['Next'] }
    to get the value in "Next". Then you should "only" parse the content in "Next" to get the "referenceName" property.

    I've tried to convert it via JSON-deserialisation (ConvertFrom-Json), but it failed, because the content is not a valid JSON serialized object, see (missing comma between properties!):
    {"type": "AzureKeyVaultSecret" "store": {

    // ValueCollection: I had a similar issue with a result of type ValueCollection in PowerShell, and this approach works in my case. In my case the object with type ValueCollection was returned by a CRM FetchXML query via the GetEntityDataByFetchSearch method. Based on the documentation, the return type should have been Dictionary<String,Dictionary<String,Object>.

    Hope it helps...

    Was this answer helpful?

    0 comments No comments

  2. Limitless Technology 40,106 Reputation points
    2022-09-12T07:46:51.137+00:00

    Hi Nandanhegde-7720,,

    Thank you for posting your query.

    To answer your query kindly check this link https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2.valuecollection?view=net-6.0 for the command provided below.

    public sealed class Dictionary<TKey,TValue>.ValueCollection : System.Collections.Generic.ICollection<TValue>, System.Collections.Generic.IEnumerable<TValue>, System.Collections.Generic.IReadOnlyCollection<TValue>, System.Collections.ICollection

    --------------------------------------------------------------------------------------------------------------------------------------------

    If the answer is helpful kindly click "Accept as Answer" and upvote it. Thanks.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.