Forum Discussion

Hank_Stallings's avatar
Hank_Stallings
Icon for Nimbostratus rankNimbostratus
Jun 11, 2010

PS iControl Dashboard Question

Hey from Nashville!!

 

 

I have a question regarding the PowerShell script (http://devcentral.f5.com/wiki/defau...board.html).

 

 

It's very cool, however in my environment we have a zillion pools...so the script takes forever to run. How can I change the script to allow for filtering based on pool name?

 

 

Line 152 of the code reads:

 

$PoolList = (Get-F5.iControl).LocalLBPool.get_list() | Sort-Object;

 

 

Can a variable be defined (like $filter=$null) that can be added to the console at runtime.

 

 

Like:

 

iControlDashboard.ps1 host uid pwd filter

 

 

So my command at runtime would look like:

 

 

PS iControlDashboard.ps1 MyBIGIP hank password dev

 

 

So that the dashboard would only show pools whose name contain "dev".

 

 

Any help is appreciated!

 

 

Hank

 

 

PS: Also when we configure nodes, we define the server name in the node record. On the node record the field is called "Name". Would like to pull that information into the dashboard as well.

4 Replies

  • Ask and you shall receive. I've updated the iControlDashboard codeshare entry with an additional input parameter for the pool and changed the line you referred to as

    $PoolList = (Get-F5.iControl).LocalLBPool.get_list() |
      Where-Object { $_.ToLower().IndexOf($Pool.ToLower()) -ne -1 } | Sort-Object;

    IndexOf will return a non-negative number if the substring is contained in the specified string. This essentially does a regular expression match to "*value*" without the overhead of a regular expression. If you only want to match to the beginning of the string, you could change the "IndexOf" to "StartsWith" or some other string function of your choice.

    Hope this helps...

    -Joe

  • Thanks Joe,

    So, when I run the script as before,

     PS c:\temp\iControlDashboard.ps1 BIGIP Username Password  

    I get an error like:

    TRAPPED: System.Management.Automation.PSInvalidCastException

    TRAPPED: Cannot convert value "22928446623" to type "System.Int32". Error: "Value was either too large or too small for an Int32."

    If I run it with:

     PS c:\temp\iControlDashboard.ps1 BIGIP Username Password "*dev*"  

    I get this error:

    TRAPPED: System.Web.Services.Protocols.SoapHeaderException

    TRAPPED: Could not find element by name: pool_names

    Thanks,

    Hank
  • If I change I make this change it works:

     

     

    $PoolList = (Get-F5.iControl).LocalLBPool.get_list() | Where-Object {$_.ToLower() -match ($Pool)} | Sort-Object;

     

     

    Thanks for your help!

     

     

    Hank
  •  

     

    PS: Also when we configure nodes, we define the server name in the node record. On the node record the field is called "Name". Would like to pull that information into the dashboard as well.

     

     

     

    The node address.screen_name is the only parameter I can't bring into this...is that a possibility?

     

     

    Thanks

     

     

    Hank