Forum Discussion
Martin_B__246_r
Nimbostratus
Sep 13, 2016list applied Irules for a specified VIP
Hi,
Is there a way to list applied Irules for a specified VIP with Powershell?
2 Replies
- Michael_Jenkins
Cirrostratus
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; - Michael_Jenkins
Cirrostratus
In that case, you could use Putty's
to execute the necessaryPlink.exe
command, like this:tmsh$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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects