Microsoft PowerShell with iControl

Updated 7/30/2013 • Originally posted on 07/29/13 by Joe Pruitt

This download is secured and you do not have access. Please login or register to view downloads.

When we shipped DC4, we started looking at Windows PowerShell and how we could build some integration points with our products. The first pass was a set of PowerShell script files that we introduced in the PowerShell Labs section of DevCentral. No soon after we posted them, the requests started pouring in on when we would provide some native PowerShell CmdLets in addition to the function scripts.

Well, I spent a little bit of time working some out and whipped out a good first rough draft. I've been holding on to these for a while now but figured they would do better out in the wild then trapped in a folder on my laptop.

So, last night I posted an installer for the first release of the iControl CmdLets for PowerShell. I also ran some screen captures on how to install and use the CmdLets but ended up with some technical difficulties with the screen capture software - Camtasia is now on order B-). So, once I can get a good capture, be on the lookout. In the mean time, here's a step by step on getting up and running with the new bits.

Download and install PowerShell from Microsoft
Go to the PowerShell Labs page on DevCentral and select the "Download Now" link.  This will download the Cmdlet installer.
Run the iControlSnapInSetup.msi installer.  This will install the SnapIn into the c:\program files\F5 Networks\iControlSnapIn directory.

Start PowerShell from the Windows Start menu.
Cd to c:\program files\F5 Networks\iControlSnapIn directory
Dot Source the setup script (only once after the install)
PS > . .\setupSnapIn.ps1)

Load the SnapIn into the Runtime
PS > Add-PSSnapIn iControlSnapIn

Initialize the iControl connection with the Initialize-F5.iControl CmdLet
PS > Initialize-F5.iControl -Hostname bigip_address -Credentials (Get-Credential)

Run the Get-F5.iControlCommands CmdLet to list out all the available Cmdlets.
PS > Get-F5.iControlCommands

Try out some of the CmdLets
PS > Get-F5.LTMPool

That should be about it. Hopefully I'll automate some of the setup procedures into the installer (if anyone knows how to get the Installer Project in VS.Net to include a shortcut to a non-project item, please let me know B-).

Rate and Subscribe
Average Rating: 4.5
Log in to rate this content
Comment made 8/16/2013 ago by Forrest Shields 0

I got an "installation failed" error when following the above instructions (my notes in ALL CAPS below): PS C:\> cd 'C:\Program Files\F5 Networks\iControlSnapIn' cd : Cannot find path 'C:\Program Files\F5 Networks\iControlSnapIn' because it does not exist. ***NOTE: IF YOU ARE ON A 64-BIT VERSION OF WINDOWS, THE PATH WILL USE "Program Files (x86)" PS C:\> cd 'C:\Program Files (x86)\F5 Networks\iControlSnapIn' PS C:\Program Files (x86)\F5 Networks\iControlSnapIn> . .\setupSnapIn.ps1 Registering iControlSnapin.dll on platform '' Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5420 Copyright (c) Microsoft Corporation. All rights reserved. The installation failed, and the rollback has been performed. Registering iControlSnapin.dll on platform '64' Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5420 Copyright (c) Microsoft Corporation. All rights reserved. The installation failed, and the rollback has been performed. *** NOTE: INSTALLATION FAILED BECAUSE YOU NEED TO RUN AN ADMINISTRATIVE POWERSHELL PROMPT IF UAC IS ENABLED. FIND YOUR POWERSHELL PROMPT FROM THE START MENU (Start --> All Programs --> Accessories --> Windows PowerShell), RIGHT-CLICK ON THE "Windows Powershell" PROGRAM ICON AND CHOOSE "Run as administrator". THEN PERFORM THE INSTALLATION STEPS IN THE ARTICLE ABOVE.

Comment made 8/21/2013 ago by Damien Solodow 1

Are the cmdets able to work with resources in partitions other than common? For example, Get-F5.LTMPool only shows pools in the /Common partition and I didn't see a parameter for it or Initialize-F5.iControl to switch partitions.

Comment made 8/29/2014 ago by Luca 0

The cmdlet is great! work very well with our version of F5 10.4. Bu trying to use with our new device version 11.5.1, I'm not able to get any info. Is suppose to work with the 11.5.1 ? If yes there is anything that have to be enable or configured on the device? Thanks in advance

Comment made 9/22/2014 ago by Hank Stallings 10

Installed the Snap-in and I'm receiving this error: Add-PSSnapIn : Cannot load Windows PowerShell snap-in iControlSnapIn because of the following error: The Windows PowerShell snap-in module C:\Program Files (x86)\F5 Networks\iControlSnapIn\iControlSnapin.dll does not have the required Windows PowerShell snap-in strong name iControlSnapIn, Version=, Culture=neutral, PublicKeyToken=null. At line:2 char:5 + Add-PSSnapIn iControlSnapIn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (iControlSnapIn:String) [Add-PSSnapin], PSSnapInException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

Comment made 9/22/2014 ago by Hank Stallings 10

Disregard my previous comment, running the below command fixed my issue: C:\WINDOWS\system32>c:\windows\Microsoft.Net\Framework64\v2.0.50727\installutil.exe "C:\Program Files (x86)\F5 Networks\iControlSnapIn\iControlSnapin.dll" /LogFile=

Comment made 9/23/2014 ago by Dominic 0

Thanks for this. How would you obtain the IP address of a VIP leveraging PowerShell? Ultimately I would like to be able to pull not only the members of a VIP and their status, but also the IP address assigned to the VIP so I can have a single report. The next step of course would be to pull certificate information of the VIP. Also, how do you query the GTM? We have a few addresses on the GTM that then ties to two LTMs. It would be nice to pull that information as well. Thanks, Dominic

Comment made 9/24/2014 ago by Grayson 171

Do these commands allow us to completely automate a new load balanced VS? I want to be able to end the nodes, their names, pools and create the VIP.

Comment made 10/17/2014 ago by R_C_P 0

I installed and configured this in my environment. It works with version "BIG-IP 11.4.1 Build 608.0 Final" but when I run Initialize-F5.iControl against version "BIG-IP 11.6.0 Build 0.0.401 Final" it fails with the following error. Any help on this would be appreciated. Initialize-F5.iControl : Could not initialize connection with supplied information At line:1 char:5 + Initialize-F5.iControl -HostName -Username user1 -Pas ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: ( [Initialize-F5.iControl], Exception + FullyQualifiedErrorId : 2,iControlSnapIn.CmdLet.Global.InitializeiControl

Comment made 10/17/2014 ago by R_C_P 0

Just to add, the credentials I use with the command above works when I use the web interface and it is an administrator account.

Comment made 3/12/2015 ago by Colyn1337 2

Would you happen to have this in a non installer form?

Comment made 3/24/2015 ago by Ken 2

is source available? or documentation

Comment made 5/20/2015 ago by David Karakas 0

I believe the problem users are experiencing with v11.5 and higher is due to the fact that F5 moved from the iControl API to iControlREST API. I don't believe iControlREST has been integrated with PowerShell yet.

Comment made 5/29/2015 ago by James 175

I got the following error trying this command - Get-iControlCommands. PS C:\Program Files (x86)\F5 Networks\iControlSnapIn> Get-iControlCommands Get-iControlCommands : The term 'Get-iControlCommands' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correc and try again. At line:1 char:1 + Get-iControlCommands + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-iControlCommands:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException I also looked and the icontrol is not listed in the cmdlet. I also tried Initialize-iControl command and got another error. Initialize-iControl : The term 'Initialize-iControl' is not recognized as the name of a cmdlet, function, script file or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Initialize-iControl -Hostname -Credentials (Get-Credential) + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Initialize-iControl:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Any help would be greatly appreceiated. I am excited to use PS with our F5s

Comment made 8/4/2015 ago by AJ 01 112

Same problem here - Running as Administrative PowerShell. Server 2012 R2

Comment made 5 months ago ago by James 175

Update: I was able to get this to work using 11.4.1 and 11.6.0. Download the file and follow the steps. Thanks!

Comment made 3 months ago ago by Almassud 251

Hi, I got to work by supplying user name and password, but I would like for it to use currently logged in user name and password so that I don't have t type the password in clear text. is that possible? Thanks MJ

Comment made 3 months ago ago by Sam Hall 133

The SnapIn produces the wrong envelope for LocalLB.Class.set_string_class_member_data_value. When I specify an array like @("val1","val2","val3"), only the 1st member gets set to "val1" and the rest of the array is ignored. Looking at the envelope in the HTTP request, it's passing the values like this [["val1"],["val2"],["val3"]] (translated to json). If I manipulate the envelope and send it so the data is sent like this, it works... [["val1","val2","val3"]].

Comment made 3 months ago ago by Joe Pruitt 5881

@Sam, the LocalLB.Class.set_string_member_data_value method looks likes this: set_string_class_member_data_value( in LocalLB__Class__StringClass [] class_members, in String [] [] values ); The second parameter is a 2-D array so you need to declare it as such with a double set of brackets. I'm assuming you were referring to the second parameter and not the first. As for the comments from others of moving from SOAP to REST, that is where we are going but as of today (v12) iControl SOAP is still being developed and having features added to it.

Comment made 2 months ago ago by cgaines22 0

@Joe, is there a way to get all of the partitions and not just the Common partition when using the get-f5.ltmpool?