Public/Connect-F5.ps1
function Connect-F5 { <# .SYNOPSIS Helper function to connect to an F5 using POSH F5-LTM module, This is required as the f5-apm module leverages the work of https://github.com/joel74/POSH-LTM-Rest for connecting and inovking ssl based Rest Requests .DESCRIPTION Creates a global varibale so that add-on functions can utilise the F5-LTM object for connectons Requires F5-LTM modules from github .PARAMETER ip The ip or dns entry of the f5 to connect to. .PARAMETER TokenLifeSpan The token lifespan for connection. Possibly in seconds no documenation is availbale. The default is set. .Example Connect-F5 -ip yourf5dns.workisfun.com #> param( [Alias('F5 IP Address')] [Parameter(Mandatory=$true)] [string]$ip, [Parameter(Mandatory=$false)] [System.Management.Automation.PSCredential]$creds ) # if( !($creds) ){ $creds = Get-Credential -Message "Please enter credentials to access the F5 load balancer" } try{ $Global:F5Session = New-F5Session -LTMName $ip -LTMCredentials $creds -Default -PassThru -ErrorAction Stop } catch{ Write-Warning "Could not connect to the F5. Please check you credentials and try again." } } |