Forum Discussion

dan_03_140075's avatar
dan_03_140075
Icon for Nimbostratus rankNimbostratus
Apr 14, 2014

How to use the iControl API reference

Hello, I am using the powershell icontrol snapin. I am finding it very difficult (newbie alert) to use the api reference to find the code required to perform actions. E.g. how do I go from https://devcentral.f5.com/wiki/iControl.System__SystemInfo__get_uptime.ashx to (Get-F5.iControl).SystemSystemInfo.get_uptime()

 

The reference shows "System::SystemInfo::get_uptime" and "long get_uptime():" but the ps that works is (Get-F5.iControl).SystemSystemInfo.get_uptime() How do I know System::SystemInfo becomes SystemSystemInfo?

 

Also in some cases I getting null valued expressions e.g. (Get-F5.iControl).NTP.Servers and (Get-F5.iControl).Management.TACACSConfiguration

 

At the moment I am totally reliant on finding actual powershell examples and of course that is very finite in what has been done. My immediate requirement is to build an audit script, have seen the sample ps one, but want to add to it e.g. ntp servers, dns servers, various ha details, etc.

 

Thanks

 

2 Replies

  • Got some of what I am after via $DBVariable=(Get-F5.iControl).ManagementDBVariable and then $DBVariable.query( ("HostName","Service.SNMP.allow","DNS.NameServers","ntp.servers","Failover.State","Failover.LinksUp","Failover.HaCable","pva.acceleration")) Still like to get hsm/fips info. No luck tracking that so far....
  • I built the iControl .Net library (which the Powershell snapin is based) by moving the module+interface into a combined string for the interface name in the .Net lib. So, System.SystemInfo will turn into SystemSystemInfo. If you are using the Get-F5.iControl cmdlet to return the core iControl.Interfaces object, you can then iterate through that object and it will return a list of all the interface objects, which in turn contain all of the methods.

     

    Here's a list of PowerShell based tech tips and code samples:

     

    https://devcentral.f5.com/wiki/iControl.PowerShell.ashx

     

    So, for an example, if you are looking at the SDK and want to get a list of VLANs in the Networking.VLAN interface with the VLAN.get_list() method, you would combine the Module and Interface and pull that object out from the Interfaces object. The get_list() method will be contained in that object.

     

    $ic = Get-F5.iControl
    $vlan = $ic.NetworkingVLAN;
    $list = $vlan.get_list();

    To get a list of all of the interfaces, just pass the Interfaces object through the Get-Command cmdlet.

     

    $ic = Get-F5.iControl
    $ic | Get-Command
    ....

    Hope this helps... -Joe