Get associated pool name from VIP IP using F5-LTM
I am trying to get the pool name from the VIP IP which I am getting from a input file, but I am unable to get any cmdlet related to that ``` $secpasswd = ConvertTo-SecureString "" -AsPlainText -Force $MyLTM_IP = "12.16.16.8" $mycreds = New-Object System.Management.Automation.PSCredential "rk", $secpasswd $session = $null #Create an F5 session $session = New-F5Session -LTMName $MyLTM_IP -LTMCredentials $mycreds -PassThru $get_data = Import-Csv -Path "D:\f5\IP_Addition_Input.csv" $VIP_IP = $get_data.VIPIP ``` Please let me know how can I get the pool name. going forward I have a add nodes to that pool. I am using `F5-LTM` module ``` # Download latest version $webclient = New-Object System.Net.WebClient $url = "https://github.com/joel74/POSH-LTM-Rest/archive/master.zip" Write-Host "Downloading latest version of F5-LTM from $url" -ForegroundColor Cyan $file = "$($env:TEMP)\F5-LTM.zip" $webclient.DownloadFile($url,$file) Write-Host "File saved to $file" -ForegroundColor Green # Unblock and decompress Unblock-File -Path $file $targetondisk = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules" # no need to handle, this folder should just exist New-Item -ItemType Directory -Force -Path $targetondisk -ErrorAction SilentlyContinue | out-null # Unzip Write-Host "Uncompressing the Zip file to $($targetondisk)" -ForegroundColor Cyan $shell_app=new-object -com shell.application $zip_file = $shell_app.namespace($file) $destination = $shell_app.namespace($targetondisk) $destination.Copyhere($zip_file.items(), 0x10) # Rename and import Write-Host "Renaming folder" -ForegroundColor Cyan if (Test-Path ($targetondisk+"\F5-LTM")) { Write-Host "Removing prior $($targetondisk+"\F5-LTM") folder" -ForegroundColor Yellow Remove-Item -Recurse -Force -Path ($targetondisk+"\F5-LTM") | out-null } Move-Item -Path ($targetondisk+"\POSH-LTM-Rest-master") -Destination "$($targetondisk+"\F5-LTM")" -Force | out-null Write-Host "Module has been installed" -ForegroundColor Green Import-Module -Name "$($targetondisk+"\F5-LTM\F5-LTM")" # Zip file has a sub F5-LTM folder with the module Get-Command -Module F5-LTM <#!-------------------#> ```28Views0likes0Commentsplink command in powershell | problem with imish
Hi I'm trying to send "imish" command via powershell to f5 and it is not working I tried: imish run /util imish -r 0 both ways did not work I also tried to send the command in the same line like this: plink admin@192.168.1.1 -pw 12345 imish and via external file like this: plink admin@192.168.1.1 -pw 12345 -m E:\myfolder\imishcommand.txt Any other command like "show" or "list" is working fine If I do it gradually, step by step, first by passing the credentials and then when I'm in I write the "imish" command, it is working fine The user I'm using has the administrator level. I also tried with the local "admin" user and the "root" user. Why I'm not able to send the imish command along with the plink command Alternatively, if there is a way to check "show ip ospf neighbor" without entering the "imish"1.1KViews0likes1CommentiControl soap
Hi! Trying to import a key/certificate with the iControl SOAP powershell snapin, but I get these errors: Exception calling "key_import_from_pem_v2" with "6" argument(s): "Exception caught in Management::urn:iControl:Management/KeyCertificate::key_import_from_pem_v2() Exception: Common::OperationFailed primary_error_code : -14 (0xFFFFFFF2) secondary_error_code : 0 error_string : Keys do not match" At C:\Scripts\LetsencryptQA\letsencrypt1.1.ps1:418 char:90 + ... rt_from_pem_v2($ManagementModetype, @($KeyName), @($StringPem), $Secu ... + ~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapHeaderException And for the certificate Exception calling "certificate_import_from_pem" with "4" argument(s): "Exception caught in Management::urn:iControl:Management/KeyCertificate::certificate_import_from_pem() Exception: Common::OperationFailed primary_error_code : -14 (0xFFFFFFF2) secondary_error_code : 0 error_string : Keys do not match" At C:\Scripts\LetsencryptQA\letsencrypt1.1.ps1:441 char:103 + ... om_pem($ManagementModetype, @($CertificateName), @($StringPem), $true ... + ~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapHeaderException ` **Importing the key with another name works though**, which would indicate that the key exists somewhere. However: `list sys file ssl-key | grep name Nothing list sys file ssl-cert | grep name Nothing ls -alR | grep name Nothing And nothing in the GUI certificate list under any partition. I have also: Done a mcpd reload and restarted the device. Manually imported the certificate and key in the Web UI (works, but then I can t reproduce the error) Any clever ideas? /Patrik321Views0likes3CommentsPowershell iControl Snapin - DISconnecting from one LTM, connecting to another - same script
We have a need to populate an address datagroup from an external database. I currently have a working proof of concept in powershell using the F5 supplied iControl snapin. Works great. However, we have a pair of LTM4000's - running active/standby. I want to cover the case where a standby swap has happened and the active is now standby. I have noticed that when I connect to the LTM using Initialize-F5.iControl that I cannot "disconnect", and that if I try to connec to to the second LTM using a second statement (with a different hostname), that all subsequent commands pull information from the FIRST connected LTM. For example, (Get-F5.iControl).ManagementDBVariable.query("hostname") will show the hostname of the first one I initialize no matter what. I'm new to powershell, and I must be missing something here. If anyone can lend a hand - the problem I'm trying to solve is: Connect to both LTM's, and determine which is active Connect to only that LTM and perform our manipulation of the address data group. Each loop through I would check and connect to only the active. Probably would also be nice to check the sync state, just in case it winds up in an inconsistent state I can abort/error. I suspect that perhaps I need to set a hostname value for each icontrol command to tell it where to go? Thanks in advance255Views0likes1CommentUsing Powershell to create an iApp Service
HI All, Long time user first time poster 🙂 I am currently tryinbg to use the REST API to automate the creatation of iApps for a project we are working on. We are trying to create a basic vServer with one pool on port 80 with no profiles, and creating this under an Application Service. using the predefied iApp http template. I am trying to use Powershell to do this, and using the PS Module that is up on GitHub (https://github.com/joel74/POSH-LTM-Rest) as the basis for my script. I have been able to run a GET and get the JSON of an existing Application Service, and changing the parameters and doing a POST it is failing with the below error Invoke-RestMethodOverride : "400 Bad Request: "name" unexpected argument At line:1 char:7 + Invoke-RestMethodOverride -Method POST -Uri "$URI" ` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-RestMethodOverride Has been driving me crazy, any recommendations? Devcentral is not letting me upload the JSON Body cause it is too long, but below is a link to download my script, it is a txt file. https://goo.gl/4Cc3z2 Thanks404Views0likes2CommentsPowerShell - How to modify system iFile?
I use PowerShell to upload a text file containing a number of parameters that I want to use in an existing iRule. Through the web-gui I have already created an iFile named 'iFileApiKeys'. In PowerShell I use this procedure to upload the text file: $length = "0-" + ($fileContent.Length - 1) + "/" + $fileContent.Length $headers = @{ "Content-Range" = $length} $uploadResult = Invoke-WebRequest $URL -Method POST -Headers $headers -InFile $filePathPlusTextfile - ContentType "multipart/form-data" -TimeoutSec 20 -Credential $mycreds | ConvertFrom-Json Write-Host "Upload Result:" Write-Host $uploadResult According to the 'uploadResult' the file ends up in the folder:'var/config/rest/downloads/iFileApiKeys.txt' on my F5 LTM Using 'SuperPutty' I can via tmos (tmsh) modify the existing system iFile by executing: `tmos> modify /sys file ifile iFileApiKeys source-path file:///var/config/rest/downloads/iFileApiKeys.txt My problem is that I can't seem to find the correct PowerShell command to achieve the same result as the tmos (tmsh) command does. I want to use and actually think I should use: `Invoke-Webrequest -Method Put` I've been trying to emulate an example taken from a Jason Rahm post on this site: https://devcentral.f5.com/articles/getting-started-with-icontrol-working-with-the-system-20592 Like this: $sysIfilePath = "/mgmt/tm/sys/file/ifile/iFileApiKeys" `$sysPath = "https://" + $host_address + $sysIfilePath $updateresult = Invoke-WebRequest -Method Put -Uri $sysPath -Headers $headers -Credential $mycreds -Body $body But this command fails unfortunately, My assumption is that I don't fill $headers and/or $body with the correct values. When executing a GET for my sys iFile object the result is: ``{"kind":"tm:sys:file:ifile:ifilestate","name":"iFileApiKeys","fullPath":"iFileApiKeys","generation":10970077,"selfLink":"https://localhost/mgmt/tm/sys/file/ifile/iFileApiKeys?ver=13.1.0.2","chec ksum":"SHA1:878:52a261b5a113db5c9421a54e1e8b5685e7da7a4d","createTime":"2018-11-26T22:52:08Z","createdBy":"per.eriksson","lastUpdateTime":"2018-12-08T19:49:15Z","mode":33188,"revision":24,"size" :878,"sourcePath":"file:///var/config/rest/downloads/iFileApiKeys.txt","updatedBy":"per.eriksson"} Anyone out there that can point me in the right direction on how to update my sys iFile using PowerShell? Thank you! /Per757Views0likes2CommentsBackup F5 BigIP using RestAPI and PowerShell (again?)
Hello! I went through the Forum and I saw a lot of related messages but none of them actually answered my question. The documentation [I found] leaves to be desired and I hope that the community is able to help me. I am looking for a simple "backup everything and store as a file" solution and it looks like it is much more than just 2-3 RestAPI calls. So, I am able to connect and get a token. Now, I am googling the "Create Backup" command and nothing works. Could you please point me to the exact link that will create a new backup? I also think that it could be a "story" to download the backup, so I will be happy to get any advice on that also. Thanks.Solved1.8KViews0likes6CommentsPowershell: Invoke-RESTmethod on /mgmt/tm/sys/ucs (403) Forbidden error
I'm fairly experienced with Powershell and have used the Invoke-RestMethod cmdlet, and vendor documentation, to automate some things before. I've just inherited management of an HA pair of F5 BIG-IPs. We're not in a position to get BIG-IQ right now, and from looking at notes the previous admin was just logging in and manually creating a UCS archive and downloading it on the weekly. Of course my first thought was that I could automate this. I was able to successfully authenticate against one of the appliances with Invoke-RestMethod and do an HTTP GET to retrieve a list of current UCS files present. However, when I change the method to POST and add in the appropraite Body parameters (in JSON) I get a 403 forbidden error: {"code":403,"message":"Operation is not allowed on component /sys/ucs.","errorStack":[],"apiError":1} the documentation here seems to allude that this should be possible: K13225405 Here's more or less what I'm working with so far: $uri = "/mgmt/tm/sys/ucs" $BigIP = "192.168.1.10" $link = "https://$BigIP$uri" $headers = @{} $headers.Add("ServerHost", $Bigip) $headers.Add("Content-Type", "application/json") $Body = @{ Name = "/var/local/ucs/test_ucs.ucs" Command = "save" } $mycreds = Get-Credential $obj = Invoke-RestMethod -Method POST -Headers $headers -Body ($Body | ConvertTo-Json) -Uri $link -Credential $mycreds3.4KViews0likes19CommentsPowershell 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???522Views0likes4CommentsiControl PS Snapin throws error when calling LocalLBPool.get_member_metadata
iControlSnapin v23 PowerShell v4.0 Hi, I am able to successfully call other LocalLBPool methods. When I attempt to call LocalLBPool.get_member_metadata I receive an error. (Get-F5.iControl).LocalLBPool.get_member_metadata(@('mypool'),@($object)) Exception calling "get_member_metadata" with "2" argument(s): "There is an error in XML document (11, 2)." At line:1 char:64 + (Get-F5.iControl).LocalLBPool.get_member_metadata(@('mypool'),@($object)) + ~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : InvalidOperationException ` Of course I run Initialize-F5.iControl first. I build my $object using this code: `$object = New-Object -TypeName iControl.CommonAddressPort $object.address = 'mynodeaddress' $object.port = 443 ` Here is an example of a method that works fine with that same object: `(Get-F5.iControl).LocalLBPool.get_member_object_status(@('mypool'),@($object)) availability_status enabled_status status_description ------------------- -------------- ------------------ AVAILABILITY_STATUS_GREEN ENABLED_STATUS_ENABLED The DNS server(s) are ... Any ideas? Is the source code for the iControlSnapin available somewhere? Thanks, pimy549Views0likes5Comments