Forum Discussion

Richard_Brookfi's avatar
Icon for Nimbostratus rankNimbostratus
Nov 13, 2010

multiple instances of PS not working

hello there. First I would like to say thank you for building such a useful tool. I have run in to a couple of issues though and would love to know if there is something i am doing wrong. Here is my dilemma.



I have application that manages connecting to all of our BigIP servers using multiple instances of PS (via activexposh)


here is a simple example of the concept using autoit:



Region ;**** Directives created by AutoIt3Wrapper_GUI ****




EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****










Region START Koda GUI section Form=


Global $Form1 = GUICreate("Form1", 625, 440, 198, 55)


Global $Input1 = GUICtrlCreateInput("Input1", 0, 64, 121, 21)


Global $Input2 = GUICtrlCreateInput("Input2", 304, 64, 121, 21)


Global $Edit1 = GUICtrlCreateEdit("", 0, 120, 305, 233)


GUICtrlSetData(-1, "Edit1")


Global $Edit2 = GUICtrlCreateEdit("", 304, 120, 313, 233)


GUICtrlSetData(-1, "Edit2")


Global $Button1 = GUICtrlCreateButton("Button1", 160, 64, 75, 25, $WS_GROUP)


Global $Button2 = GUICtrlCreateButton("Button2", 464, 64, 75, 25, $WS_GROUP)




Global $psObj = ObjCreate("SAPIEN.ActiveXPoSH")


Global $psObj2 = ObjCreate("SAPIEN.ActiveXPoSH")


Global $init1 = $psObj2.Init("True")


Global $init2 = $psObj.Init("True")




EndRegion END Koda GUI section




While 1


$nMsg = GUIGetMsg()


Switch $nMsg






case $Button1


$cmd1 = GUICtrlRead($Input1)


$psObj.OutputMode = $OUTPUT_BUFFER




GUICtrlSetData($Edit1, $psObj.outputstring)




case $Button2


$cmd2 = GUICtrlRead($Input2)


$psObj2.OutputMode = 2




GUICtrlSetData($Edit2, $psObj2.outputstring)













So by looking at this you can see that i have 2 groups of a edit box and output window tied to a instance of power shell. Now if I take one set and change to 1 directory and I execute DIR and then execute DIR on the other group I come up with different results. I will show me one directory listing and the other will show me something completely different. However, If I use the icontrol snap-in and connect to one BigIP server with one group and then I connect to a different BigIP server with the other group and then run get-f5.ltmpool in each group. It will only display the results for the last BigIP server I logged into (for both) Its like even though I am using 2 independent instances of power shell the connection between the 2 (for BigIP) is shared... I have found that if I just open 2 power shell windows on my desktop the connections to BigIP servers are not shared. Is there something with your snap-in that references my application's (as a whole) instance? I have tried to figure out if the issue lies with the snap-in or if it is with the activexposh. But I tend to think this has something to do with the snap-in because I have been able to confirm that the instances of power shell are in fact independent but executing other commands not related to icontrol.


1 Reply

  • Richard, sorry for the delayed response, for some reason I missed this post in my notification list in my email.

    The iControl Snapin uses a single internal connection instance. If you are using it within the same runspace, there is only a single internal iControl.Interfaces object. So, if you call Initialize-F5.iControl multiple times it will just overwrite the internal Interfaces object.

    Now, that doesn't mean you can't use multiple connections from within PowerShell. It just means you can't do it with the Initialize-F5.iControl cmdlet.

    What I would do would be to instantiate multiple instances of iControl.Interfaces objects and then call the local "initialize()" method on each of them. Then use those interface objects for your two connections. Something like this:

    $iControl1 = New-Object -TypeName iControl.Interfaces
    $iControl1.initialize("bigip1", "bigip1_user", "bigip1_pass");
    $iControl2 = New-Object -TypeName iControl.Interfaces
    $iControl2.initialize("bigip2", "bigip2_user", "bigip2"pass");
    $bigip1_pool_list = $iControl1.LocalLBPool.get_list();
    $bigip2_pool_list = $iControl2.LocalLBPool.get_list();

    Note that now you wouldn't be using the Get-F5.iControl cmdlet (which essentially returns the internal iControl.Interfaces object). You would be creating the object yourself and then referencing it locally.

    Hope this helps...