microsoft powershell with icontrol
68 TopicsHow can I create member with name using powershell cmdlet?
How can you create pool members with descriptive names? When I create a new vm, I'm able to automatically add it to a pool. Add-F5.LTMPoolMember -Pool $PoolName -Member "${VMIP}:${Port}" However the name of the node is its ip address. I've also tried using the more low level way of adding a node $PoolList = @($PoolName) $Node = New-Object -TypeName iControl.CommonAddressPort; $Node.address = $VMIP $Node.port = $Port (Get-F5.iControl).LocalLBPool.add_member_v2($PoolList, $Node) I can't find any way to change the node name with add_member_v2452Views0likes2CommentsQuery Current Connections at the Node Level
I am working on Powershell scripts to do automated deployments to our servers behind our BIG-IP LTM. I have simple scripts that use the iControl powershell cmdlets Disable-F5.LTMNodeAddress -Node xxx.xxx.xxx.xxx These work quite well, however, what I need next is a way to query the Current Connections to the node as they bleed off so that my automation doesn't begin the deployment until current connections = 0. I'm assuming I'm just not formatting my searches right as someone must have figured this out by now. Any help would be greatly appreciated. Thanks!186Views0likes0CommentsiControlRest - Using Powershell's Invoke-RestMethod to obtain connections stats from pool members?
Hi, I'm hoping someone can help here, I'm 2 days and counting and have hit a brick-wall on it. I personally have doubts if this can work, although I'd like to think it is possible. I'm writing a script in Powershell to monitor the serverside.curConns value and return it using Powershell. The plan is to incorporate this into a bigger script to allow a server reboot once the value reaches 0 At the moment, we have 8 (and growing) servers in this pool, and the idea is to run this on each server when it goes to do a system restart during patching. I only want to change the values at the top of my script, so this script will remain unchanged across the 8 servers when copied locally. For example, lets say the 8 servers are named... PROD_SERVER01 to PROD_SERVER08 My script is below. ======= CHANGE PER ENVIRONMENT ========== $f5partition = "Production" $f5poolname = "Frontend_App_pool" $f5port = 8080 $user = "myf5userid" $pass = "myf5password" $f5server = "myf5server.mydomain.local" ======= NO CHANGES BELOW THIS LINE! ======= $servername = $env:COMPUTERNAME ====== AUTHORISATION SECTION ========== $pair = "$($user):$($pass)" $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) $basicAuthValue = "Basic $encodedCreds" $Headers = @{ Authorization = $basicAuthValue } === CONNECT TO F5 API ========= $reply = Invoke-RestMethod -Uri https://${f5server}/mgmt/tm/ltm/pool/~${f5partition}~${f5poolname}/members/~${f5partition}~${servername}:${f5port}/stats/?$select=serverside.curConns -Headers $Headers My JSON results will look like this...Just like the ones detailed in the IControlRest pdf manual...results below truncated for readability... { "generation": 263285, "kind": "tm:ltm:pool:members:membersstats", "selfLink": "https://localhost/mgmt/tm/ltm/pool/~Production~Frontend_App_pool/members/~Production~PROD_SERVER01:8080/stats?ver=12.1.3", "entries": { "https://localhost/mgmt/tm/ltm/pool/~Production~Frontend_App_pool/members/~Production~PROD_SERVER01:8080/~Production~PROD_SERVER01:8080/stats": { "nestedStats": { "kind": "tm:ltm:pool:members:membersstats", "selfLink": "https://localhost/mgmt/tm/ltm/pool/~Production~Frontend_App_pool/members/~Production~PROD_SERVER01:8080/~Production~PROD_SERVER01:8080/stats?ver=12.1.3", "entries": { "serverside.curConns": { "value": 0 } } } } } } If I run the script above once, I then have the JSON loaded into the $reply variable. Using Powershell ISE, if I then construct a WRITE-HOST statement and start typing, the remaining will fill in automatically. For example, I started with $reply. then the first entry is $reply.entries and so on, until I can find what I want... Write-Host $reply.entries.'https://localhost/mgmt/tm/ltm/pool/~Production~Frontend-App_pool/members/~Production~PROD_SERVER01:8080/~Production~PROD_SERVER01:8080/stats'.nestedStats.entries.'serverside.curConns'.value This will display the value to the screen My problem is that I am having trouble writing the script to run on PROD_SERVERS02-08, because that above WRITE-HOST statement uses fixed properties. I've tried lots of variable substitutions on this line to no avail. I'm also struggling to do anything constructive with enumerating through the multi-tiered JSON in a loop to extract the value. Any help greatly received! Thanks in advance. I'm trying to write something that doesn't have any baggage with it, so not downloading curl .exes or pre-built functions to cart around server-to-server. Neil585Views0likes0CommentsFind a node using LocalLBNodeAddressV2 based on IP address (not name)
Hello. We have some iControl PowerShell scripts that we're using with our Private Cloud (IaaS) platform to add/remove VIPs, Pools and Nodes. Previously we were using LTM v10 so we couldn't set a friendly name for the node. Once we upgraded to v11 we started to set the "name" to match the actual server name. So for example we might have SERVER0121 as the node's Name and 192.168.1.17 as the node's address. It has been working fine, but now we've run into a situation where we have stale data - servers that are in the F5 but should have been removed and never were. So we're running into the following error: Exception calling "create" with "3" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/NodeAddressV2::create() Exception: Common::OperationFailed primary_error_code : 17237812 (0x01070734) secondary_error_code : 0 error_string : 01070734:3: Configuration error: invalid node address, the IP address 10.27.197.106 already exists" So I'd like to be able to remove these stale entries as we see them. But I'm not sure how to remove this node based on IP address only. For example if I try delete_node_address using the IP address. Exception calling "delete_node_address" with "1" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/NodeAddressV2::delete_node_address() Exception: Common::OperationFailed primary_error_code : 16908342 (0x01020036) secondary_error_code : 0 error_string : 01020036:3: The requested node address (/Common/10.27.197.117) was not found." At line:1 char:1 + (Get-F5.iControl).LocalLBNodeAddressV2.delete_node_address($server_ip); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapHeaderException It's expecting the "name" which is SERVER0117. So how do I remove the node based only on IP address? Thanks. Rezilient340Views0likes4CommentsClearing of RAM-Cache or Web Acceleration profiles
I need a way to clear the web cache from off box. I'm playing around with PowerShell for iControl but don't see any ramcache related commands listed. I found a sample script the references the 'Get-RAMCacheEntry' command but this doesn't seem to exist any more. Basically, I need a good way of doing what this command does without giving my application people CLI access to the big-ip. tmsh delete ltm profile ramcache [cache profile name] Ideas? Thanks, Patrick581Views0likes5CommentsPowershell and iControl : ManagementDeviceGroup.get_list
Hi, We are using Powershell and iControl to make some job on our F5 BigIP. I am trying to get the Group Device list with the follow commands line : 01 $f5_server_01 = "servername" 02 $f5_user_01 = "admin" 03 $f5_password_01 = "password" 04 $ic_01 = New-Object iControl.Interfaces 05 $ic_01.initialize("$f5_server_01", "$f5_user_01", "$f5_password_01") 06 $ic_01.ManagementDeviceGroup.get_list() When every thing is ok, the last line (06) should return something like this : /Common/HA-Sync /Common/device_trust_group /Common/gtm But some time to time, it is retunring nothing, and I have to wait a while before it come back 😞 Is anyone already get this problem ? Is there any iControl limitation ? Thank for you help. JB261Views0likes3CommentsHow do I read the send string for a monitor using powershell icontrol?
I have an (unknown) number of monitors that look at an asp page. I need to create an equivalent monitor for each of these that looks at the new htm page. My thought was to script this using powershell and icontrol. I want to look at all the send string on each monitor on an LTM, if the send string contains the name of the asp page, create a new monitor based on that monitor name referencing the new htm page. But I can't seem to pull the send string off the monitor. I've googled around and i see examples for listing, adding and removing monitors - but not listing the details of a monitor. I'm currently (failing) using the following: $sv = New-Object -TypeName iControl.LocalLBMonitorStringValue $sv.type = 'STYPE_SEND' $monitorname = 'rollout' $Control.locallbmonitor.get_template_user_defined_string_property(@($monitorname),@($sv.type)) I get the following error: Exception calling "get_template_user_defined_string_property" with "2" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/Monitor::get_template_user_defined_string_property() Exception: Common::OperationFailed primary_error_code : 16908342 (0x01020036) secondary_error_code : 0 error_string : 01020036:3: The requested monitor parameter (rollout_HTTPS 1 STYPE_SEND=) was not found." At line:1 char:89 + ... lout_HTTPS"),@($sv.type)) + ~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapHeaderException303Views0likes1CommentNot able to setup iControlSnapIn
Hi All I have installed the f5-icontrol-powershell-snapin.zip from link text I ran the setupSnapIn.ps1 but got the below error Registering iControlSnapin.dll on platform '' .NET v4 present Microsoft (R) .NET Framework Installation utility Version 4.6.1590.0 Copyright (C) Microsoft Corporation. All rights reserved. The installation failed, and the rollback has been performed. Registering iControlSnapin.dll on platform '64' .NET v4 present Microsoft (R) .NET Framework Installation utility Version 4.6.1590.0 Copyright (C) Microsoft Corporation. All rights reserved. The installation failed, and the rollback has been performed. I am doing this on a WinSevrer2008R2 with PS 5.0 Please let me know what is the issue.450Views0likes1CommentPowershell Error
We have a automated job to enable and disable a nodes in a pool.. i am using the ps1 from here - LINK Passing the following params - powershell.exe -noexit C:\Temp\icontrol\test.ps1 10.10.10.11 admin password pool_server 10.10.10.13:80 disable powershell.exe -noexit C:\Temp\icontrol\test.ps1 10.10.10.11 admin password pool_server 10.10.10.13:80 enable when running through the disabled, i get the following weird error, Disabling Session Enabled State... Waiting for current connections to drop to zero... Current Connections: 0 Disabling Monitor State... Exception calling "set_monitor_state" with "2" argument(s): "Client found respo nse content type of 'text/html; charset=iso-8859-1', but expected 'text/xml'. The request failed with the error message: -- 500 Internal Server Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, support@f5.com and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. --." At E:\icontrol\test.ps1:212 char:56 + (Get-F5.iControl).LocalLBPoolMember.set_monitor_state <<<< ( (, $pool_name) , $MemberMonitorStateAofA); + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException Write-Host : The OS handle's position is not what FileStream expected. Do not u se a handle simultaneously in one FileStream and in Win32 code or another FileS tream. This may cause data loss. At E:\icontrol\test.ps1:100 char:17 + Write-Host <<<< "Pool $pool_name, Member ${member_addr}:${member_port} status:" + CategoryInfo : NotSpecified: (:) [Write-Host], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Comma nds.WriteHostCommand Write-Host : The OS handle's position is not what FileStream expected. Do not u se a handle simultaneously in one FileStream and in Win32 code or another FileS tream. This may cause data loss. At E:\icontrol\test.ps1:101 char:17 + Write-Host <<<< " Availability : $Availability" + CategoryInfo : NotSpecified: (:) [Write-Host], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Comma nds.WriteHostCommand Write-Host : The OS handle's position is not what FileStream expected. Do not u se a handle simultaneously in one FileStream and in Win32 code or another FileS tream. This may cause data loss. At E:\icontrol\test.ps1:102 char:17 + Write-Host <<<< " Enabled : $Enabled" + CategoryInfo : NotSpecified: (:) [Write-Host], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Comma nds.WriteHostCommand Write-Host : The OS handle's position is not what FileStream expected. Do not u se a handle simultaneously in one FileStream and in Win32 code or another FileS tream. This may cause data loss. At E:\icontrol\test.ps1:103 char:17 + Write-Host <<<< " Description : $Description" + CategoryInfo : NotSpecified: (:) [Write-Host], IOException + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Comma nds.WriteHostCommand the enable portion works just fine - Setting Montior State to Enabled Setting Session Enabled State to Enabled Pool pool_server, Member 10.10.10.13:80 status: Availability : AVAILABILITY_STATUS_BLUE Enabled : ENABLED_STATUS_ENABLED Description : Pool member does not have service checking enabled Any ideas or clues anyone???523Views0likes4CommentsiControlSnapIn Problems
I'm at the end of my wits here, I've read through all the guides, followed each of them to a word, I've been through several uninstalls and restarts and I'm still nowhere near getting this snapin to work... Without further adieu, here's the complete list of errors I've been getting for the last several hours: Post install: Get-F5.LTMPool : The term 'Get-F5.LTMPool' 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 + Get-F5.LTMPool + ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-F5.LTMPool:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException I guess I'd better try to add the snap-in again: 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=11.2.0.0, Culture=neutral, PublicKeyToken=null. At C:\dev\ARM-Tools\Code Snippets\Shane\F5Helper.psm1:9 char:5 + Add-PSSnapIn iControlSnapIn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (iControlSnapIn:String) [Add-PSSnapin], PSSnapInException + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand I resolved that by forcing a remove and then an add of the snap-in: Unregistering iControlSnapin.dll on platform '' Microsoft (R) .NET Framework Installation utility Version 2.0.50727.7905 Copyright (c) Microsoft Corporation. All rights reserved. Unregistering iControlSnapin.dll on platform '64' Microsoft (R) .NET Framework Installation utility Version 2.0.50727.7905 Copyright (c) Microsoft Corporation. All rights reserved. Registering iControlSnapin.dll on platform '' Microsoft (R) .NET Framework Installation utility Version 2.0.50727.7905 Copyright (c) Microsoft Corporation. All rights reserved. Registering iControlSnapin.dll on platform '64' Microsoft (R) .NET Framework Installation utility Version 2.0.50727.7905 Copyright (c) Microsoft Corporation. All rights reserved. Another attempt at using one of the cmdlets available through the snap-in: Initialize-F5.iControl : The term 'Initialize-F5.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-F5.iControl + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Initialize-F5.iControl:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Maybe it didn't add the first 2 times, I should try it again: PS C:\program files (x86)\F5 Networks\iControlSnapin> Add-PSSnapIn iControlSnapIn Add-PSSnapIn : An item with the same key has already been added. At line:1 char:1 + Add-PSSnapIn iControlSnapIn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-PSSnapin], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.AddPSSnapinCommand Looks like it's already there, I'd better remove it because it's not working: PS C:\program files (x86)\F5 Networks\iControlSnapin> Remove-PSSnapIn iControlSnapIn Remove-PSSnapIn : No Windows PowerShell snap-ins matching the pattern 'iControlSnapIn' were found. Check the pattern and then try the command again. At line:1 char:1 + Remove-PSSnapIn iControlSnapIn + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (iControlSnapIn:String) [Remove-PSSnapin], PSArgumentException + FullyQualifiedErrorId : NoPSSnapInsFound,Microsoft.PowerShell.Commands.RemovePSSnapinCommand So I uninstall and reinstall and follow the guides again, just to get another failure message: Get-F5.LTMPool : The term 'Get-F5.LTMPool' 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 + Get-F5.LTMPool + ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-F5.LTMPool:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException I'm running Windows 8.1, 64-bit, PS v.4. Can anyone help me get this going?Solved1.2KViews0likes12Comments