Most efficient way to re-prioritize a virtual server's iRules?
I'm writing a powershell script to add and remove a maintenance page redirect iRule to the top of a given virtual server's iRule list (TMOS versions 9.4.x and 10.x). Any given virtual server that this script would run against would already have a list of iRules applied to it.
To my chagrin, it appears that there's no way to directly change the priority of iRules already assigned to a virtual server, so it seems that I have to:
1. dump the existing list of iRules (and their original priorities) to a 2-dimensional array (storing .rule_name and .priority)
2. add 1 to the value of all their priorities
3. add the maintenance page redirect iRule to the virtual server (with a priority of 0)
4. add back all of the original iRules with their modified priorities
5. do the reverse when it's time to remove the maint page redirect iRule
NOTE: I could store the original irule names and priorities, NOT change their priorities, and then just add them back after removing the maint page redirect iRule, but then I'd need to reliably store the original iRule information somewhere where ANYONE on the team can re-apply the original iRules from any of a number of different workstations, and it's just not worth the additional complexity. By leaving all of the original iRules applied to the virtual (with modified priorities) it's easy for any admin running the script to remove the maint redirect iRule at any time, from any of their workstations. Anyway ...
I was going to simply dump the results of this query to a 2-dimensional array, but the results appear to come back as one field:
PS C:\> $rule_list = (Get-F5.iControl).LocalLBVirtualServer.get_rule((, $vs_name))
PS C:\> $rule_list | Format-Table -AutoSize
PS C:\> $rule_list.count
Can anyone please suggest the most efficient way to do this sort of iRule priority swapping via iControl and Powershell?