Hashtable in powershell

Asked

Viewed 48 times

0

I apologize in advance for my inexperience! So I have the following hashtable:

@{Name=Useragent; Value=Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0} @{Name=Flowtokenscenario; Value=Login} @{Name=Userauthenticationmethod; Value=1} @{Name=Requesttype; Value=Login:login} @{Name=Resultstatusdetail; Value=Success}

And I needed to select the "value" in which the "name" is Useragent and dial the others.

For example: $hash.value[0] returns to me "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0"

I liked, if possible, something like: $hash.name['Useragent'] and somehow return me the associated value.

I thank you for your time!!

1 answer

0

I think I solved my problem this way:

foreach ($key in $hash.getenumerator()) { if ($key.name -eq "useragent") { $key value. } }

I don’t know if it was the right way, but it seems to have worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.