Reputation: 247
I am pulling some details about providers back from my application via a GET Invoke-RestMethod
.
Currently it is returning all the details about providers. I want to only return the code of providers where the active status is set to True.
$acctname = 'user1'
$password = 'secret'
$params = @{uri = 'http://localhost:8080/tryout/settings/provider/providerDetails';
Method = 'Get';
Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($acctname):$($password)"))
} #end headers hash table
} #end $params hash table
# This gets all the basic info ok
$var = invoke-restmethod @params
#show the values in the console
echo $var
It currently returns all these details. All I need is just the code if active-true.
id : 90
name : Test 1
active : True
code : NOT_STATED
system : False
objectVersion : 2
id : 91
name : Test 2
active : True
code : MAIN
system : False
objectVersion : 3
id : 20372
name : Test 3
active : True
code : NOT_STATED
system : True
objectVersion : 2
id : 30382
name : Test 4
active : True
code : OP
system : False
objectVersion : 1
Upvotes: 2
Views: 6650
Reputation: 59001
Just pipe $var
to the Where-Object
cmdlet and filter them:
$var | Where-Object active -eq 'True'
Upvotes: 7