Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Create new webclient object
  2. $WebClient = New-Object System.Net.WebClient
  3. #Enable integrated authentication
  4. $WebClient.UseDefaultCredentials = $true
  5.  
  6. #Get the json objects
  7. $Virtualservers = ($WebClient.DownloadString("http://loadbalancing.se/bigipreportdemo/json/virtualservers.json")) | ConvertFrom-Json
  8. $pools = ($WebClient.DownloadString("http://loadbalancing.se/bigipreportdemo/json/pools.json")) | ConvertFrom-Json
  9.  
  10. #Get the pools that contains "/Common/worker01.int.local"
  11. $Poolselection = $($pools | Where-Object { $_.members.name -contains "/Common/worker01.int.local" }).name
  12.  
  13. #Loop through the virtual servers
  14. Foreach($vs in $VirtualServers){
  15.    
  16.     foreach($Pool in $vs.Pools){
  17.         if($Poolselection -Contains $Pool){
  18.             #We found a match, print out the $vs
  19.             $vs
  20.             #If more than one pool is matched on this vs we don't want to print it twice, so we exit the inner loop
  21.             Break
  22.         }
  23.     }
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement