【发布时间】:2017-02-03 20:04:50
【问题描述】:
我正在通过 GET Invoke-RestMethod 从我的应用程序中提取有关提供程序的一些详细信息。
目前它正在返回有关提供者的所有详细信息。我只想返回活动状态设置为 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
它当前返回所有这些详细信息。如果 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
【问题讨论】: