1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$username = "admin" $secure_string_pwd = convertto-securestring "admin" -asplaintext -force $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,$secure_string_pwd) $url_rabbit = "http://r01-crm01:15672/api/queues" try { $web_queues = Invoke-WebRequest -Uri $url_rabbit -Method GET -Credential $credentials $jsn = $web_queues | ConvertFrom-Json #$jsn.name $msg_cnt = @{} foreach ($q in $jsn.name) { $json_web = Invoke-WebRequest -Uri "$url_rabbit/%2F/$q" -Method GET -Credential $credentials $jsnw = $json_web | ConvertFrom-Json $msg_cnt += @{$q = $jsnw.messages} } $msg_cnt } catch { $_.Exception.Message } |