For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

2 Replies

  • While all this could be done in fewer lines just as easily, here's some code that should help using iControlRest.

     

    $f5Host = "f5.example.com";
    $f5Cred = (Get-Credential);
    $prefix = "https://$f5Host/mgmt/tm";
    $vip    = "/MY_VIP_NAME";                        You can leave this variable blank to return all the VIPs and their iRules
    $resp   = Invoke-RestMethod -Method GET -Uri "$prefix/ltm/virtual$($vip)?`$select=fullPath,rules" -Credential $f5Cred;
    $list   = ($resp.items, $resp, 1 -ne $null)[0];  REF: http://stackoverflow.com/questions/10623907/null-coalescing-in-powershell
    $list;
  • In that case, you could use Putty's

    Plink.exe
    to execute the necessary
    tmsh
    command, like this:

    $f5Host     = "f5.example.com";
    $f5Cred     = (Get-Credential);
    $plinkPath  = 'c:\PATH\TO\plink.exe';
    $vip        = "MY_VIP_NAME";  Or blank for all VIPs
    $tCmd       = "tmsh list ltm virtual $vip rules";
    $command    = "& `"$plinkPath`" -l ""{0}"" -pw ""{1}"" {2} ""{3}""" -f @($f5Cred.Username, $f5Cred.GetNetworkCredential().Password, $f5Host, $tCmd);
    $response   = Invoke-Expression $command;
    $response;
    

    You'll will have to parse the response to get the data in a more usable format, however.

    You could also use the older SOAP based iControl, but I don't have an example for that one.