diff --git a/F5-LTM/F5-LTM.Tests.ps1 b/F5-LTM/F5-LTM.Tests.ps1 index 01b59d0..905b3d1 100644 --- a/F5-LTM/F5-LTM.Tests.ps1 +++ b/F5-LTM/F5-LTM.Tests.ps1 @@ -44,6 +44,8 @@ Describe 'Get-BigIPPartition' -Tags 'Unit' { $Link -replace 'localhost', $this.Name } -PassThru + # Add the mock session to the Script scope + $Script:F5Session = $mocksession #endregion Arrange: Initialize Mocks It "Requests BigIP partitions *" { diff --git a/F5-LTM/F5-LTM.psd1 b/F5-LTM/F5-LTM.psd1 index bcc0bbf..d97bfcb 100644 --- a/F5-LTM/F5-LTM.psd1 +++ b/F5-LTM/F5-LTM.psd1 @@ -21,10 +21,10 @@ GUID = 'f4649254-d64a-407d-822f-66a4618ed5fb' Author = 'Joel Newton' # Company or vendor of this module -CompanyName = 'SpringCM, a DocuSign company' +CompanyName = '' # Copyright statement for this module -Copyright = '(c) 2020 Joel Newton. All rights reserved.' +Copyright = '(c) 2023 Joel Newton. All rights reserved.' # Description of the functionality provided by this module Description = 'This module uses the REST API in the F5 LTM v11.6 and higher to query and manipulate the F5 LTM device.' diff --git a/F5-LTM/Private/Add-ObjectDetail.ps1 b/F5-LTM/Private/Add-ObjectDetail.ps1 index 8d08c78..34200b2 100644 --- a/F5-LTM/Private/Add-ObjectDetail.ps1 +++ b/F5-LTM/Private/Add-ObjectDetail.ps1 @@ -11,19 +11,19 @@ Helper function to decorate an object with - A TypeName - New properties - - Default parameters + - Default parameters .PARAMETER InputObject Object to decorate. Accepts pipeline input. .PARAMETER TypeName Typename to insert. - + This will show up when you use Get-Member against the resulting object. - + .PARAMETER PropertyToAdd Add these noteproperties. - + Format is a hashtable with Key (Property Name) = Value (Property Value). Example to add a One and Date property: @@ -86,7 +86,7 @@ .NOTES This breaks the 'do one thing' rule from certain perspectives... The goal is to decorate an object all in one shot - + This abstraction simplifies decorating an object, with a slight trade-off in performance. For example: 10,000 objects, add a property and typename: @@ -98,7 +98,7 @@ .LINK https://raw.githubusercontent.com/RamblingCookieMonster/PSStash/master/PSStash/Private/Add-ObjectDetail.ps1 #> - [cmdletBinding()] + [cmdletBinding()] param( [Parameter( Mandatory = $false, Position=0, @@ -110,7 +110,7 @@ [string]$TypeName, [Parameter( Mandatory = $false, - Position=2)] + Position=2)] [System.Collections.Hashtable]$PropertyToAdd, [Parameter( Mandatory = $false, @@ -121,7 +121,7 @@ [boolean]$Passthru = $True ) - + Begin { if($PSBoundParameters.ContainsKey('DefaultProperties')) @@ -142,7 +142,7 @@ foreach($Key in $PropertyToAdd.Keys) { #Add some noteproperties. Slightly faster than Add-Member. - $Object.PSObject.Properties.Add( ( New-Object PSNoteProperty($Key, $PropertyToAdd[$Key]) ) ) + $Object.PSObject.Properties.Add( ( New-Object PSNoteProperty($Key, $PropertyToAdd[$Key]) ) ) } } 'TypeName' diff --git a/F5-LTM/Private/ArgumentCompletion.ps1 b/F5-LTM/Private/ArgumentCompletion.ps1 index 4c5a8eb..93161f4 100644 --- a/F5-LTM/Private/ArgumentCompletion.ps1 +++ b/F5-LTM/Private/ArgumentCompletion.ps1 @@ -2,8 +2,8 @@ $Script:F5LTMPublicCommands = Get-ChildItem -Path ($PSScriptRoot -replace 'Private','Public') -Filter '*.ps1' -Recurse | Select-Object -ExpandProperty BaseName function Get-F5Command { <# -.SYNOPSIS - (Get-Command -Module F5-LTM) adversely affects module import performance. +.SYNOPSIS + (Get-Command -Module F5-LTM) adversely affects module import performance. This is a much faster alternative without resorting to static command names for Register-ArgumentCompleter -Command parameters. #> @@ -27,15 +27,15 @@ function CompleteMonitorName { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-HealthMonitor -F5Session $Session -Partition $fakeBoundParameters.Partition -Type $fakeBoundParameters.Type | Where-Object { $_.name -like "$wordToComplete*" } | ForEach-Object { if ($fakeBoundParameters.Partition) { $_.name } else { - $_.fullPath + $_.fullPath } - } + } } } function CompleteMonitorType { @@ -44,7 +44,7 @@ function CompleteMonitorType { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-HealthMonitorType -F5Session $Session | Where-Object { $_ -like "$wordToComplete*" } } @@ -55,10 +55,10 @@ function CompleteNodeAddress { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { - Get-Node -F5Session $Session -Partition $fakeBoundParameters.Partition | - Where-Object { $_.address -like "$wordToComplete*" } | + Get-Node -F5Session $Session -Partition $fakeBoundParameters.Partition | + Where-Object { $_.address -like "$wordToComplete*" } | Select-Object -ExpandProperty address } } @@ -68,15 +68,15 @@ function CompleteNodeName { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-Node -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" } | ForEach-Object { if ($fakeBoundParameters.Partition) { $_.name } else { - $_.fullPath + $_.fullPath } - } + } } } function CompleteBIGIPPartition { @@ -85,7 +85,7 @@ function CompleteBIGIPPartition { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-BIGIPPartition -F5Session $Session | Where-Object { $_ -like "$wordToComplete*" } } @@ -97,10 +97,10 @@ function CompletePoolMemberAddress { $commandAst, $fakeBoundParameters) if ($fakeBoundParameters.PoolName) { - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { - Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Name (Invoke-NullCoalescing {$fakeBoundParameters.Name} {'*'}) | - Where-Object { $_.address -like "$wordToComplete*" } | + Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Name (Invoke-NullCoalescing {$fakeBoundParameters.Name} {'*'}) | + Where-Object { $_.address -like "$wordToComplete*" } | Select-Object -ExpandProperty address } } @@ -112,10 +112,10 @@ function CompletePoolMemberName { $commandAst, $fakeBoundParameters) if ($fakeBoundParameters.PoolName) { - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { - Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Address (Invoke-NullCoalescing {$fakeBoundParameters.Address} {'*'}) | - Where-Object { $_.name -like "$wordToComplete*" } | + Get-PoolMember -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition -Address (Invoke-NullCoalescing {$fakeBoundParameters.Address} {'*'}) | + Where-Object { $_.name -like "$wordToComplete*" } | Select-Object -ExpandProperty name } } @@ -127,10 +127,10 @@ function CompletePoolMonitorName { $commandAst, $fakeBoundParameters) if ($fakeBoundParameters.PoolName) { - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { - Get-PoolMonitor -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition | - Where-Object { $_.name -match "\b$wordToComplete*" } | + Get-PoolMonitor -F5Session $Session -PoolName $fakeBoundParameters.PoolName -Partition $fakeBoundParameters.Partition | + Where-Object { $_.name -match "\b$wordToComplete*" } | Select-Object -ExpandProperty name } } @@ -141,15 +141,15 @@ function CompletePoolName { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-Pool -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" -or $_.fullPath -like "$wordToComplete*" } | ForEach-Object { if ($fakeBoundParameters.Partition) { $_.name } else { - $_.fullPath + $_.fullPath } - } + } } } function CompleteRuleName { @@ -158,15 +158,15 @@ function CompleteRuleName { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-iRule -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" -or $_.fullPath -like "$wordToComplete" } | ForEach-Object { if ($fakeBoundParameters.Partition) { $_.name } else { - $_.fullPath + $_.fullPath } - } + } } } function CompleteVirtualServerName { @@ -175,15 +175,15 @@ function CompleteVirtualServerName { $wordToComplete, $commandAst, $fakeBoundParameters) - $Session = Get-CompleteSession $fakeBoundParameters.F5Session + $Session = Get-CompleteSession $fakeBoundParameters.F5Session if ($Session) { Get-VirtualServer -F5Session $Session -Partition $fakeBoundParameters.Partition | Where-Object { $_.name -like "$wordToComplete*" -or $_.fullPath -like "$wordToComplete" } | ForEach-Object { if ($fakeBoundParameters.Partition) { $_.name } else { - $_.fullPath + $_.fullPath } - } + } } } if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore) @@ -232,17 +232,17 @@ if (Get-Command Register-ArgumentCompleter -ErrorAction Ignore) -CommandName @(Get-F5Command '*') ` -ParameterName Partition ` -ScriptBlock $function:CompletePartition - + Register-ArgumentCompleter ` -CommandName 'Get-BIGIPPartition' ` -ParameterName Name ` -ScriptBlock $function:CompleteBIGIPPartition - + Register-ArgumentCompleter ` -CommandName @(Get-F5Command '*-Pool*') ` -ParameterName PoolName ` -ScriptBlock $function:CompletePoolName - + Register-ArgumentCompleter ` -CommandName 'Get-iRule' ` -ParameterName Name ` diff --git a/F5-LTM/Private/Invoke-F5RestMethod.ps1 b/F5-LTM/Private/Invoke-F5RestMethod.ps1 index 86f2696..179144b 100644 --- a/F5-LTM/Private/Invoke-F5RestMethod.ps1 +++ b/F5-LTM/Private/Invoke-F5RestMethod.ps1 @@ -4,7 +4,7 @@ Function Invoke-F5RestMethod { [OutputType([Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject])] [OutputType([String])] [OutputType([bool])] - param ( + param ( [Parameter(Mandatory)][Microsoft.PowerShell.Commands.WebRequestMethod]$Method, [Parameter(Mandatory)][uri]$URI, [Parameter(Mandatory)]$F5Session, @@ -40,10 +40,10 @@ Function Invoke-F5RestMethod { try { $message = $_.ErrorDetails.Message | ConvertFrom-json | Select-Object -expandproperty message } catch { - $message = [string]$_.ErrorDetails.Message + $message = [string]$_.ErrorDetails.Message } - $ErrorOutput = '"{0} {1}: {2}' -f $_.Exception.Response.StatusCode.value__,$_.Exception.Response.StatusDescription,(Invoke-NullCoalescing {$message} {$ErrorMessage}) + $ErrorOutput = '"{0} {1}: {2}' -f $_.Exception.Response.StatusCode.value__,$_.Exception.Response.StatusDescription,(Invoke-NullCoalescing {$message} {$ErrorMessage}) Write-Error $ErrorOutput - } + } } } \ No newline at end of file diff --git a/F5-LTM/Private/Invoke-NullCoalescing.ps1 b/F5-LTM/Private/Invoke-NullCoalescing.ps1 index e4ddbe1..4bbde25 100644 --- a/F5-LTM/Private/Invoke-NullCoalescing.ps1 +++ b/F5-LTM/Private/Invoke-NullCoalescing.ps1 @@ -24,9 +24,9 @@ Function Invoke-NullCoalescing { [Parameter(ValueFromPipeline, ParameterSetName='InputObject')] [psobject] $InputObject - ) - - Process { + ) + + Process { if ($pscmdlet.ParameterSetName -eq 'InputObject') { if ($PrimaryExpr -eq $null) { Foreach-Object $AlternateExpr -InputObject $InputObject diff --git a/F5-LTM/Private/Join-Object.ps1 b/F5-LTM/Private/Join-Object.ps1 index cf97e55..c6bfdad 100644 --- a/F5-LTM/Private/Join-Object.ps1 +++ b/F5-LTM/Private/Join-Object.ps1 @@ -43,7 +43,7 @@ $AllProperty = $LeftProperty + $RightProperty | Select-Object -Unique $LeftGroups = $Left | Group-Object $($On) -AsHashTable -AsString - $RightGroups = $Right | Group-Object $($OnRight) -AsHashTable -AsString + $RightGroups = $Right | Group-Object $($OnRight) -AsHashTable -AsString } process { if ($null -eq $Left -and $null -eq $Right) { diff --git a/F5-LTM/Private/Resolve-NestedStats.ps1 b/F5-LTM/Private/Resolve-NestedStats.ps1 index 1f34159..3486aa3 100644 --- a/F5-LTM/Private/Resolve-NestedStats.ps1 +++ b/F5-LTM/Private/Resolve-NestedStats.ps1 @@ -3,7 +3,7 @@ .SYNOPSIS Between v11.6 and v12.0, there were breaking changes in regards to the JSON format returned for various iControlREST requests, such as when retrieving the system version or pool member stats. Specifically, instead of the data existing in an "entries" property directly underneath the parent JSON object, it is now enclosed in "nestedStats" property within a custom PS object whose name resembles a self-link with the member name repeated. - + To resolve this discrepancy, this function performs version-specific transformations to the JSON data and returns it in a standardized format with the "entries" property at the top. #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "")] diff --git a/F5-LTM/Public/Get-BIGIPPartition.ps1 b/F5-LTM/Public/Get-BIGIPPartition.ps1 index 402d70b..aa055a3 100644 --- a/F5-LTM/Public/Get-BIGIPPartition.ps1 +++ b/F5-LTM/Public/Get-BIGIPPartition.ps1 @@ -28,7 +28,7 @@ } $URI = ($F5Session.BaseURL -replace 'ltm/','sys/folder') + '/{0}?$select=name,subPath' -f $itemname $JSON = Invoke-F5RestMethod -Method Get -Uri $URI -F5Session $F5Session - Invoke-NullCoalescing {$JSON.items} {$JSON} | + Invoke-NullCoalescing {$JSON.items} {$JSON} | Where-Object { $_.subPath -eq '/' -and ([string]::IsNullOrEmpty($Name) -or $Name -contains $_.name) } | Select-Object -ExpandProperty name } diff --git a/F5-LTM/Public/Get-F5Status.ps1 b/F5-LTM/Public/Get-F5Status.ps1 index aee1211..05a0832 100644 --- a/F5-LTM/Public/Get-F5Status.ps1 +++ b/F5-LTM/Public/Get-F5Status.ps1 @@ -1,6 +1,6 @@ Function Get-F5Status{ <# -.SYNOPSIS +.SYNOPSIS Test whether the specified F5 is currently in active or standby failover mode #> [cmdletBinding()] diff --git a/F5-LTM/Public/Get-HealthMonitor.ps1 b/F5-LTM/Public/Get-HealthMonitor.ps1 index b5e5f52..5129ce7 100644 --- a/F5-LTM/Public/Get-HealthMonitor.ps1 +++ b/F5-LTM/Public/Get-HealthMonitor.ps1 @@ -19,7 +19,7 @@ [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [string]$Partition, - + [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [string[]]$Type ) diff --git a/F5-LTM/Public/Get-HealthMonitorType.ps1 b/F5-LTM/Public/Get-HealthMonitorType.ps1 index b51b347..1715c28 100644 --- a/F5-LTM/Public/Get-HealthMonitorType.ps1 +++ b/F5-LTM/Public/Get-HealthMonitorType.ps1 @@ -19,10 +19,10 @@ foreach ($itemname in $Name) { $URI = $F5Session.BaseURL + 'monitor/' $JSON = Invoke-F5RestMethod -Method Get -Uri $URI -F5Session $F5Session - $JSON.items.reference | ForEach-Object { + $JSON.items.reference | ForEach-Object { [Regex]::Match($_.Link,'(?<=/)[^/?]*(?=\?)').Value | Where-Object { $_ -like $itemname } } } - } + } } diff --git a/F5-LTM/Public/Get-Node.ps1 b/F5-LTM/Public/Get-Node.ps1 index 2a038b7..97066f2 100644 --- a/F5-LTM/Public/Get-Node.ps1 +++ b/F5-LTM/Public/Get-Node.ps1 @@ -1,43 +1,43 @@ -Function Get-Node { -<# -.SYNOPSIS - Retrieve specified Node(s) -.NOTES - This function makes no attempt to resolve names to ip addresses. If you are having trouble finding a node, try: - Get-Node | Where-Object { $_.address -like 'N.N.N.N' -or $_.name -like 'XXXXX' } -#> - [cmdletBinding()] - param ( - $F5Session=$Script:F5Session, +# Function Get-Node { +# <# +# .SYNOPSIS + # Retrieve specified Node(s) +# .NOTES + # This function makes no attempt to resolve names to ip addresses. If you are having trouble finding a node, try: + # Get-Node | Where-Object { $_.address -like 'N.N.N.N' -or $_.name -like 'XXXXX' } +> + # [cmdletBinding()] + # param ( + # $F5Session=$Script:F5Session, - [Parameter(ValueFromPipelineByPropertyName)] - [PoshLTM.F5Address[]]$Address=[PoshLTM.F5Address]::Any, + # [Parameter(ValueFromPipelineByPropertyName)] + # [PoshLTM.F5Address[]]$Address=[PoshLTM.F5Address]::Any, - [Alias('ComputerName')] - [Alias('NodeName')] - [Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)] - [string[]]$Name='', + # [Alias('ComputerName')] + # [Alias('NodeName')] + # [Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName)] + # [string[]]$Name='', - [Parameter(ValueFromPipelineByPropertyName)] - [string]$Partition - ) - begin { - #Test that the F5 session is in a valid format - Test-F5Session($F5Session) + # [Parameter(ValueFromPipelineByPropertyName)] + # [string]$Partition + # ) + # begin { + Test that the F5 session is in a valid format + # Test-F5Session($F5Session) - Write-Verbose "NB: Node names are case-specific." - } - process { - for($i=0; $i -lt $Name.Count -or $i -lt $Address.Count; $i++) { - $itemname = Invoke-NullCoalescing {$Name[$i]} {''} - $itemaddress = Invoke-NullCoalescing {$Address[$i]} {[PoshLTM.F5Address]::Any} - $URI = $F5Session.BaseURL + 'node/{0}' -f (Get-ItemPath -Name $itemname -Partition $Partition) - $JSON = Invoke-F5RestMethod -Method Get -Uri $URI -F5Session $F5Session - #BIG-IP v 11.5 does not support FQDN nodes, and hence nodes require IP addresses and have no 'ephemeral' property - Invoke-NullCoalescing {$JSON.items} {$JSON} | - Where-Object { $F5Session.LTMVersion.Major -eq '11' -or $_.ephemeral -eq 'false' } | - Where-Object { [PoshLTM.F5Address]::IsMatch($itemaddress, $_.address) } | - Add-ObjectDetail -TypeName 'PoshLTM.Node' - } - } -} \ No newline at end of file + # Write-Verbose "NB: Node names are case-specific." + # } + # process { + # for($i=0; $i -lt $Name.Count -or $i -lt $Address.Count; $i++) { + # $itemname = Invoke-NullCoalescing {$Name[$i]} {''} + # $itemaddress = Invoke-NullCoalescing {$Address[$i]} {[PoshLTM.F5Address]::Any} + # $URI = $F5Session.BaseURL + 'node/{0}' -f (Get-ItemPath -Name $itemname -Partition $Partition) + # $JSON = Invoke-F5RestMethod -Method Get -Uri $URI -F5Session $F5Session + BIG-IP v 11.5 does not support FQDN nodes, and hence nodes require IP addresses and have no 'ephemeral' property + # Invoke-NullCoalescing {$JSON.items} {$JSON} | + # Where-Object { $F5Session.LTMVersion.Major -eq '11' -or $_.ephemeral -eq 'false' } | + # Where-Object { [PoshLTM.F5Address]::IsMatch($itemaddress, $_.address) } | + # Add-ObjectDetail -TypeName 'PoshLTM.Node' + # } + # } +# } \ No newline at end of file diff --git a/F5-LTM/Public/Get-NodeStats.ps1 b/F5-LTM/Public/Get-NodeStats.ps1 index 67c132b..73105e5 100644 --- a/F5-LTM/Public/Get-NodeStats.ps1 +++ b/F5-LTM/Public/Get-NodeStats.ps1 @@ -17,7 +17,7 @@ [Alias('NodeName')] [Parameter(Mandatory=$true,ValueFromPipeline,ValueFromPipelineByPropertyName)] [string[]]$Name='' - + ) begin { #Test that the F5 session is in a valid format diff --git a/F5-LTM/Public/Get-PoolMember.ps1 b/F5-LTM/Public/Get-PoolMember.ps1 index 4a97abe..66869ed 100644 --- a/F5-LTM/Public/Get-PoolMember.ps1 +++ b/F5-LTM/Public/Get-PoolMember.ps1 @@ -49,7 +49,7 @@ [Regex]::Match($this.selfLink, '(?<=pool/)[^/]*') -replace '~','/' } -Force -PassThru | Add-Member -Name GetFullName -MemberType ScriptMethod { '{0}{1}' -f $this.GetPoolName(),$this.fullPath - } -Force -PassThru | Add-ObjectDetail -TypeName 'PoshLTM.PoolMember' + } -Force -PassThru | Add-ObjectDetail -TypeName 'PoshLTM.PoolMember' } } PoolName { diff --git a/F5-LTM/Public/Get-PoolMonitor.ps1 b/F5-LTM/Public/Get-PoolMonitor.ps1 index 20b5ebd..50355fc 100644 --- a/F5-LTM/Public/Get-PoolMonitor.ps1 +++ b/F5-LTM/Public/Get-PoolMonitor.ps1 @@ -27,7 +27,7 @@ Test-F5Session($F5Session) Write-Verbose "NB: Pool and monitor names are case-specific." - + $monitors = @{} } process { @@ -37,7 +37,7 @@ $InputObject = Get-Pool -F5Session $F5Session -Partition $Partition } ($InputObject | Select-Object -ExpandProperty monitor -ErrorAction SilentlyContinue) -split ' and ' | ForEach-Object { - $monitorname = $_.Trim() + $monitorname = $_.Trim() if ($Name -eq '*' -or $Name -contains $monitorname) { $monitors[$monitorname]++ } @@ -50,7 +50,7 @@ } end { foreach ($key in $monitors.Keys) { - [pscustomobject]@{Name=$key;Count=$monitors[$key]} - } + [pscustomobject]@{Name=$key;Count=$monitors[$key]} + } } } diff --git a/F5-LTM/Public/Get-ProfileHttp.ps1 b/F5-LTM/Public/Get-ProfileHttp.ps1 index d260ad4..68e8340 100644 --- a/F5-LTM/Public/Get-ProfileHttp.ps1 +++ b/F5-LTM/Public/Get-ProfileHttp.ps1 @@ -26,7 +26,7 @@ process { foreach ($itemname in $Name) { $URI = $F5Session.BaseURL + 'profile/http/{0}' -f (Get-ItemPath -Name $itemname -Partition $Partition) - $JSON = Invoke-F5RestMethod -Method Get -Uri $URI -F5Session $F5Session + $JSON = Invoke-F5RestMethod -Method Get -Uri $URI -F5Session $F5Session if ($JSON.items -or $JSON.name) { $items = Invoke-NullCoalescing {$JSON.items} {$JSON} $items | Add-ObjectDetail -TypeName 'PoshLTM.ProfileHttp' diff --git a/F5-LTM/Public/Get-VirtualServer.ps1 b/F5-LTM/Public/Get-VirtualServer.ps1 index d5f5080..09aaaa4 100644 --- a/F5-LTM/Public/Get-VirtualServer.ps1 +++ b/F5-LTM/Public/Get-VirtualServer.ps1 @@ -14,7 +14,7 @@ Function Get-VirtualServer{ } } - $VS_iRules | ForEach { $_.Rules = (Get-VirtualServer -Name $_.Name -Partition $_.Partition | Select-Object -ExpandProperty rules -ErrorAction SilentlyContinue ) } + $VS_iRules | ForEach { $_.Rules = (Get-VirtualServer -Name $_.Name -Partition $_.Partition | Select-Object -ExpandProperty rules -ErrorAction SilentlyContinue ) } #> [cmdletBinding()] @@ -66,8 +66,8 @@ Function Get-VirtualServer{ #Excluding subcollections has a significant performance increase If (!$ExcludeSubcollections) { - #Retrieve all subcollections' contents - $subcollections = [Array] $items | Get-Member -MemberType NoteProperty | % Name | % { $items.$_ } | Where { $_.isSubcollection -eq 'True' } + #Retrieve all subcollections' contents + $subcollections = [Array] $items | Get-Member -MemberType NoteProperty | % Name | % { $items.$_ } | Where { $_.isSubcollection -eq 'True' } #Add properties for policies and profiles $items | Add-Member -NotePropertyName 'policies' -NotePropertyValue @() diff --git a/F5-LTM/Public/Get-iRule.ps1 b/F5-LTM/Public/Get-iRule.ps1 index ad4534e..f7a40b7 100644 --- a/F5-LTM/Public/Get-iRule.ps1 +++ b/F5-LTM/Public/Get-iRule.ps1 @@ -8,7 +8,7 @@ [cmdletBinding()] param( $F5Session=$Script:F5Session, - + [Alias("iRuleName")] [Parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]]$Name='', diff --git a/F5-LTM/Public/Invoke-RestMethodOverride.ps1 b/F5-LTM/Public/Invoke-RestMethodOverride.ps1 index 0358075..1084c6b 100644 --- a/F5-LTM/Public/Invoke-RestMethodOverride.ps1 +++ b/F5-LTM/Public/Invoke-RestMethodOverride.ps1 @@ -4,7 +4,7 @@ Function Invoke-RestMethodOverride { [OutputType([Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject])] [OutputType([String])] [OutputType([bool])] - param ( + param ( [Parameter(Mandatory=$true)][Microsoft.PowerShell.Commands.WebRequestMethod]$Method, [Parameter(Mandatory=$true)][uri]$URI, diff --git a/F5-LTM/Public/New-F5Session.ps1 b/F5-LTM/Public/New-F5Session.ps1 index 0aa9d77..2ebe2a5 100644 --- a/F5-LTM/Public/New-F5Session.ps1 +++ b/F5-LTM/Public/New-F5Session.ps1 @@ -4,7 +4,7 @@ Generate an F5 session object to be used in querying and modifying the F5 LTM .DESCRIPTION This function takes the DNS name or IP address of the F5 LTM device, and a PSCredential credential object - for a user with permissions to work with the REST API. Based on the scope value, it either returns the + for a user with permissions to work with the REST API. Based on the scope value, it either returns the session object (local scope) or adds the session object to the script scope It takes an optional parameter of TokenLifespan, a value in seconds between 300 and 36000 (5 minutes and 10 hours). NB: If you need to connect to an LTM on other than the standard HTTPS port of 443, please include that port in the LTM name. I.e. $LTMName = '192.168.1.1:8443' @@ -35,7 +35,7 @@ #If we fail to get an auth token, that means the LTM version is prior to 11.6, so we fall back on Credentials $AuthURL = "https://$LTMName/mgmt/shared/authn/login" $JSONBody = @{username = $LTMCredentials.username; password=$LTMCredentials.GetNetworkCredential().password; loginProviderName='tmos'} | ConvertTo-Json -WarningAction $WarningPreference - + try { $Result = Invoke-RestMethodOverride -Method POST -Uri $AuthURL -Body $JSONBody -Credential $LTMCredentials -ContentType 'application/json' @@ -43,7 +43,7 @@ $Token = $Result.token.token $session.Headers.Add('X-F5-Auth-Token', $Token) - #A UUID is returned by LTM v11.6. This is needed for modifying the token. + #A UUID is returned by LTM v11.6. This is needed for modifying the token. #For v12+, the name value is used. If ($Result.token.uuid){ $TokenReference = $Result.token.uuid; @@ -67,7 +67,7 @@ # Add token expiration time to session $ts = New-TimeSpan -Minutes ($TokenLifespan/60) - $date = Get-Date -Date $Result.token.startTime + $date = Get-Date -Date $Result.token.startTime $ExpirationTime = $date + $ts $session.Headers.Add('Token-Expiration', $ExpirationTime) @@ -96,8 +96,8 @@ Token = $Token } | Add-Member -Name GetLink -MemberType ScriptMethod { param($Link) - $Link -replace 'localhost', $this.Name - } -PassThru + $Link -replace 'localhost', $this.Name + } -PassThru If ($PSVersionTable.PSVersion -lt '7.2') { $WarningPreference = $OriginalWarningPreference @@ -107,7 +107,7 @@ # We'll add it to the session object and reference it in cases where the iControlREST web services differ between LTM versions. $VersionURL = $BaseURL.Replace('ltm/','sys/version/') $JSON = Invoke-F5RestMethod -Method Get -Uri $VersionURL -F5Session $newSession | ConvertTo-Json -WarningAction $WarningPreference -Depth 10 - + $version = '0.0.0.0' # Default value, rather than throw error if ($JSON -match '(\d+\.?){3,4}') { $version = [Regex]::Match($JSON,'(\d+\.?){3,4}').Value diff --git a/F5-LTM/Public/New-HealthMonitor.ps1 b/F5-LTM/Public/New-HealthMonitor.ps1 index 0155163..4c01336 100644 --- a/F5-LTM/Public/New-HealthMonitor.ps1 +++ b/F5-LTM/Public/New-HealthMonitor.ps1 @@ -5,23 +5,23 @@ .EXAMPLE New-HealthMonitor -F5Session $F5Session -Name "/Common/test123" -Type http -Receive '^HTTP.1.[0-2]\s([2|3]0[0-9])' -Send 'HEAD /host.ashx?isup HTTP/1.1\r\nHost: Test123.dyn-intl.com\r\nConnection: close\r\n\r\n' - + New-HealthMonitor -F5Session $F5Session -Name "/Common/test123" -Type http -Receive '^HTTP.1.[0-2]\s([2|3]0[0-9])' -Send 'HEAD /host.ashx?isup HTTP/1.1\r\nHost: Test123.dyn-intl.com\r\nConnection: close\r\n\r\n' -Destination '*.80' - + New-HealthMonitor -F5Session $F5Session -Name "/Common/test123" -Type http -Receive '^HTTP.1.[0-2]\s([2|3]0[0-9])' -Send 'HEAD /host.ashx?isup HTTP/1.1\r\nHost: Test123.dyn-intl.com\r\nConnection: close\r\n\r\n' -Destination '10.1.1.1.80' -Description 'My Test Monitor' -#> +#> [cmdletBinding()] param ( $F5Session=$Script:F5Session, - + [Alias('HealthMonitorName')] [Alias('MonitorName')] [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]]$Name, - + [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [string]$Partition, - + [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [string]$Type, @@ -53,15 +53,15 @@ process { $URI = $F5Session.BaseURL + "monitor/$Type" foreach($monitorname in $Name) { - $newitem = New-F5Item -Name $monitorname -Partition $Partition + $newitem = New-F5Item -Name $monitorname -Partition $Partition #Check whether the specified pool already exists If (Test-HealthMonitor -F5session $F5Session -Name $newitem.Name -Partition $newitem.Partition -Type $Type){ Write-Error "The /$Type$($newitem.FullPath) health monitor already exists." } else { #Start building the JSON for the action - $JSONBody = @{name=$newitem.Name;partition=$newitem.Partition;recv=$Receive;send=$Send;interval=$Interval;timeout=$Timeout;destination=$Destination;description=$Description} | - ConvertTo-Json - + $JSONBody = @{name=$newitem.Name;partition=$newitem.Partition;recv=$Receive;send=$Send;interval=$Interval;timeout=$Timeout;destination=$Destination;description=$Description} | + ConvertTo-Json + # Caused by a bug in ConvertTo-Json https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088243-provide-option-to-not-encode-html-special-characte # '<', '>', ''' and '&' are replaced by ConvertTo-Json to \\u003c, \\u003e, \\u0027, and \\u0026. The F5 API doesn't understand this. Change them back. $ReplaceChars = @{ @@ -71,7 +71,7 @@ '\\u0026' = "&" } - foreach ($Char in $ReplaceChars.GetEnumerator()) + foreach ($Char in $ReplaceChars.GetEnumerator()) { $JSONBody = $JSONBody -replace $Char.Key, $Char.Value } diff --git a/F5-LTM/Public/New-Node.ps1 b/F5-LTM/Public/New-Node.ps1 index 2f7bd7a..8f3cda9 100644 --- a/F5-LTM/Public/New-Node.ps1 +++ b/F5-LTM/Public/New-Node.ps1 @@ -58,10 +58,10 @@ #Process all nodes with IP addresses for ([int]$a=0; $a -lt $Address.Count; $a++) { $itemname = $Name[$a] - if ([string]::IsNullOrWhiteSpace($itemname)) { + if ([string]::IsNullOrWhiteSpace($itemname)) { $itemname = $Address[$a].ToString() } - $newitem = New-F5Item -Name $itemname -Partition $Partition + $newitem = New-F5Item -Name $itemname -Partition $Partition #Check whether the specified node already exists If (Test-Node -F5session $F5Session -Name $newitem.Name -Partition $newitem.Partition){ Write-Error "The $($newitem.FullPath) node already exists." @@ -82,10 +82,10 @@ #Process all nodes with fully qualified domain names for ([int]$a=0; $a -lt $Name.Count; $a++) { $itemname = $Name[$a].ToString() - if ([string]::IsNullOrWhiteSpace($itemname)) { + if ([string]::IsNullOrWhiteSpace($itemname)) { $itemname = $FQDN[$a].ToString() - } - $newitem = New-F5Item -Name $itemname -Partition $Partition + } + $newitem = New-F5Item -Name $itemname -Partition $Partition $itemfqdn = $FQDN[$a] #Check whether the specified node already exists If (Test-Node -F5session $F5Session -Name $newitem.Name -Partition $newitem.Partition){ diff --git a/F5-LTM/Public/New-Pool.ps1 b/F5-LTM/Public/New-Pool.ps1 index bc1a516..39ead25 100644 --- a/F5-LTM/Public/New-Pool.ps1 +++ b/F5-LTM/Public/New-Pool.ps1 @@ -4,7 +4,7 @@ Function New-Pool { Create a new pool. Optionally, add pool members to the new pool .DESCRIPTION - Expects the $MemberDefinitionList param to be an array of strings. + Expects the $MemberDefinitionList param to be an array of strings. Each string should contain a computer name and a port number, comma-separated. Optionally, it can contain a description of the member. @@ -13,17 +13,17 @@ Function New-Pool { New-Pool -F5Session $F5Session -PoolName "MyPoolName" -MemberDefinitionList @("Server1,80,Web server,1","Server2,443,Another web server,2") If you don't use route domains, leave that value blank. -#> +#> [cmdletBinding()] param ( $F5Session=$Script:F5Session, [Alias('PoolName')] [Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]]$Name, - + [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [string]$Partition, - + [string]$Description, [ValidateSet('dynamic-ratio-member','dynamic-ratio-node','fastest-app-response','fastest-node','least-connections-member','least-connections-node','least-sessions','observed-member','observed-node','predictive-member','predictive-node','ratio-least-connections-member','ratio-least-connections-node','ratio-member','ratio-node','ratio-session','round-robin','weighted-least-connections-member','weighted-least-connections-node')] @@ -41,7 +41,7 @@ Function New-Pool { } process { foreach ($poolname in $Name) { - $newitem = New-F5Item -Name $poolname -Partition $Partition + $newitem = New-F5Item -Name $poolname -Partition $Partition #Check whether the specified pool already exists If (Test-Pool -F5session $F5Session -Name $newitem.Name -Partition $newitem.Partition){ Write-Error "The $($newitem.FullPath) pool already exists." diff --git a/F5-LTM/Public/Remove-F5Session.ps1 b/F5-LTM/Public/Remove-F5Session.ps1 index d1dbc61..bcac4ed 100644 --- a/F5-LTM/Public/Remove-F5Session.ps1 +++ b/F5-LTM/Public/Remove-F5Session.ps1 @@ -8,11 +8,11 @@ Function Remove-F5Session { $F5Session = $Script:F5Session, [switch]$SkipCertificateCheck ) - #Validate F5Session + #Validate F5Session Test-F5Session($F5Session) try { - + if ($SkipCertificateCheck) { if ($PSVersionTable.PSVersion.Major -ge 6) { diff --git a/F5-LTM/Public/Remove-HealthMonitor.ps1 b/F5-LTM/Public/Remove-HealthMonitor.ps1 index ff81fbb..d6918cd 100644 --- a/F5-LTM/Public/Remove-HealthMonitor.ps1 +++ b/F5-LTM/Public/Remove-HealthMonitor.ps1 @@ -5,7 +5,7 @@ .NOTES Health monitor names are case-specific. #> - [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact="Low")] + [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact="Low")] param( $F5Session=$Script:F5Session, diff --git a/F5-LTM/Public/Remove-PoolMember.ps1 b/F5-LTM/Public/Remove-PoolMember.ps1 index 7936cee..5ddcb50 100644 --- a/F5-LTM/Public/Remove-PoolMember.ps1 +++ b/F5-LTM/Public/Remove-PoolMember.ps1 @@ -58,7 +58,7 @@ } PoolName { $PoolMember = Get-PoolMember -F5session $F5Session -PoolName $PoolName -Partition $Partition -Address $Address -Name $Name -Application $Application; - If ($PoolMember) { + If ($PoolMember) { $PoolMember | Remove-PoolMember -F5session $F5Session } Else { diff --git a/F5-LTM/Public/Remove-PoolMonitor.ps1 b/F5-LTM/Public/Remove-PoolMonitor.ps1 index 59a9265..d216402 100644 --- a/F5-LTM/Public/Remove-PoolMonitor.ps1 +++ b/F5-LTM/Public/Remove-PoolMonitor.ps1 @@ -1,11 +1,11 @@ Function Remove-PoolMonitor { <# .SYNOPSIS - Remove health monitor(s) from a pool + Remove health monitor(s) from a pool .NOTES Health monitor names are case-specific. #> - [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact="Low")] + [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact="Low")] param( $F5Session=$Script:F5Session, diff --git a/F5-LTM/Public/Remove-VirtualServer.ps1 b/F5-LTM/Public/Remove-VirtualServer.ps1 index 5e8793d..bc87c39 100644 --- a/F5-LTM/Public/Remove-VirtualServer.ps1 +++ b/F5-LTM/Public/Remove-VirtualServer.ps1 @@ -5,7 +5,7 @@ .NOTES Virtual server names are case-specific. #> - [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact="High")] + [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact="High")] param ( $F5Session=$Script:F5Session, diff --git a/F5-LTM/Public/Remove-iRuleFromVirtualServer.ps1 b/F5-LTM/Public/Remove-iRuleFromVirtualServer.ps1 index 89c187b..e819a97 100644 --- a/F5-LTM/Public/Remove-iRuleFromVirtualServer.ps1 +++ b/F5-LTM/Public/Remove-iRuleFromVirtualServer.ps1 @@ -11,14 +11,14 @@ [Parameter(Mandatory=$true,ParameterSetName='InputObject',ValueFromPipeline=$true)] [PSObject[]]$InputObject, - + [Alias("VirtualServer")] [Alias("VirtualServerName")] [Parameter(Mandatory=$true,ParameterSetName='Name',ValueFromPipeline=$true)] [string[]]$Name, [Parameter(Mandatory=$false)] [string]$Partition='Common', - + [Parameter(Mandatory=$true)] [string]$iRuleName, @@ -46,7 +46,7 @@ $iRules = @() } - #Check that the specified iRule is not already in the collection + #Check that the specified iRule is not already in the collection If ($iRules -match $iRuleFullName){ $iRules = $iRules | Where-Object { $_ -ne $iRuleFullName } diff --git a/F5-LTM/Public/Set-Pool.ps1 b/F5-LTM/Public/Set-Pool.ps1 index fd10bd8..5b12fc3 100644 --- a/F5-LTM/Public/Set-Pool.ps1 +++ b/F5-LTM/Public/Set-Pool.ps1 @@ -16,22 +16,22 @@ Set-Pool -Name 'northwindtraders_servers' -Description 'Northwind Traders example' -LoadBalancingMode dynamic-ratio-member Creates or updates a Pool. Note that parameters that are Mandatory for New-Pool (Name and LoadBalancingMode) must be specified for Pools that do not yet exist. - + .EXAMPLE Set-Pool -Name 'northwindtraders_servers' -Description 'Some useful description' - + Sets the description of an existing Pool. .EXAMPLE Set-Pool -Name 'northwindtraders_servers' -MemberDefinitionList {192.168.1.100,80},{192.168.1.101,80} - + .EXAMPLE $pool = Get-Pool -Name 'northwindtraders_servers'; $pool.minActiveMembers = if ($pool.minActiveMembers -lt 3) { 3 }; $pool | Set-Pool -PassThru; Set the minimum active pool members to 3 if currently less than 3 and returns the resulting Pool with -PassThru. - + #> [cmdletbinding(ConfirmImpact='Medium',SupportsShouldProcess,DefaultParameterSetName="Default")] param ( @@ -57,7 +57,7 @@ #endregion #region New-Pool equivalents - + [string]$Description, [ValidateSet('dynamic-ratio-member','dynamic-ratio-node','fastest-app-response','fastest-node','least-connections-member','least-connections-node','least-sessions','observed-member','observed-node','predictive-member','predictive-node','ratio-least-connections-member','ratio-least-connections-node','ratio-member','ratio-node','ratio-session','round-robin','weighted-least-connections-member','weighted-least-connections-node')] @@ -69,7 +69,7 @@ [switch]$PassThru ) - + begin { Test-F5Session -F5Session ($F5Session) @@ -85,7 +85,7 @@ monitor='monitor' } } - + process { if ($InputObject -and ( ($Name -and $Name -cne $InputObject.name) -or @@ -98,7 +98,7 @@ $NewProperties = @{} # A hash table to facilitate splatting of New-Pool params $ChgProperties = @{} # A hash table of PSBoundParameters to override InputObject properties - + # Build out both hashtables based on $PSBoundParameters foreach ($key in $PSBoundParameters.Keys) { switch ($key) { @@ -114,7 +114,7 @@ } } } - + $ExistingPool = Get-Pool -F5Session $F5Session -Name $Name -Application $Application -Partition $Partition -ErrorAction SilentlyContinue if ($null -eq $ExistingPool) { @@ -125,13 +125,13 @@ # This performs the magic necessary for ChgProperties to override $InputObject properties $NewObject = Join-Object -Left $InputObject -Right ([pscustomobject]$ChgProperties) -Join FULL -WarningAction SilentlyContinue if ($null -ne $NewObject -and $pscmdlet.ShouldProcess($F5Session.Name, "Setting Pool $Name")) { - + # We only update the pool if properties other than 'Name' are passed in If ($NewObject | Get-Member -MemberType NoteProperty | Where-Object Name -ne 'Name'){ Write-Verbose -Message 'Setting Pool details...' - $URI = $F5Session.BaseURL + 'pool/{0}' -f (Get-ItemPath -Name $Name -Application $Application -Partition $Partition) + $URI = $F5Session.BaseURL + 'pool/{0}' -f (Get-ItemPath -Name $Name -Application $Application -Partition $Partition) $JSONBody = $NewObject | ConvertTo-Json -Compress #region case-sensitive parameter names diff --git a/F5-LTM/Public/Set-iRule.ps1 b/F5-LTM/Public/Set-iRule.ps1 index 5fdf690..807035f 100644 --- a/F5-LTM/Public/Set-iRule.ps1 +++ b/F5-LTM/Public/Set-iRule.ps1 @@ -1,4 +1,4 @@ -Function Set-iRule +Function Set-iRule { <# .SYNOPSIS @@ -33,20 +33,20 @@ [Alias('Overwrite')] [switch]$Force ) - + begin { Test-F5Session -F5Session ($F5Session) $URI = ($F5Session.BaseURL + 'rule') } - + process { $newitem = New-F5Item -Name $Name - + $kind = 'tm:ltm:rule:rulestate' - + $iRuleFullName = "/$Partition/$Name" - + $JSONBody = @{ kind = $kind name = $newitem.Name @@ -54,9 +54,9 @@ fullPath = $newitem.Name apiAnonymous = $iRuleContent } - + $JSONBody = $JSONBody | ConvertTo-Json -Compress - + # Caused by a bug in ConvertTo-Json https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088243-provide-option-to-not-encode-html-special-characte # '<', '>', ''' and '&' are replaced by ConvertTo-Json to \\u003c, \\u003e, \\u0027, and \\u0026. The F5 API doesn't understand this. Change them back. $ReplaceChars = @{ @@ -66,13 +66,13 @@ '\\u0026' = "&" } - foreach ($Char in $ReplaceChars.GetEnumerator()) + foreach ($Char in $ReplaceChars.GetEnumerator()) { $JSONBody = $JSONBody -replace $Char.Key, $Char.Value } - + $iRuleonServer = Get-iRule -Name $newitem.Name -Partition $Partition -ErrorAction SilentlyContinue - + if ($iRuleonServer) { if ($iRuleonServer.apiAnonymous -eq $iRuleContent) @@ -81,7 +81,7 @@ $iRulesDifferent = $false $true } - + else { $iRulesDifferent = $True @@ -89,9 +89,9 @@ if ($Force) { Write-Verbose -Message 'iRule on server is different from current version, and Force flag was set. Removing the iRule from VirtualServer and adding the new one.' - + $VirtualServers = Get-VirtualServer | Where-Object -Property rules -EQ -Value $iRuleFullName - + foreach ($Virtualserver in $VirtualServers) { if ($pscmdlet.ShouldProcess($Virtualserver.Name, "Remove iRule $Name from VirtualServer")) @@ -99,28 +99,28 @@ $Null = $Virtualserver | Remove-iRuleFromVirtualServer -iRuleName $Name } } - + if ($pscmdlet.ShouldProcess($F5Session.Name, "Deleting iRule $Name")) { $URIOldiRule = $F5Session.GetLink($iRuleonServer.selfLink) Invoke-F5RestMethod -Method DELETE -URI $URIOldiRule -F5Session $F5Session } } - + else { Write-Warning -Message 'iRule on server is different from current version, use -Force to overwrite current iRule.' } } } - + if ( (-not $iRuleonServer) -or ($iRuleonServer -and $iRulesDifferent -and $Force) ) { if ($pscmdlet.ShouldProcess($F5Session.Name, "Uploading iRule $Name")) { Invoke-F5RestMethod -Method POST -URI "$URI" -F5Session $F5Session -Body $JSONBody -ContentType 'application/json' -AsBoolean } - + foreach ($Virtualserver in $VirtualServers) { if ($pscmdlet.ShouldProcess($Virtualserver.Name, "Add iRule $Name")) diff --git a/F5-LTM/Public/Test-F5Session.ps1 b/F5-LTM/Public/Test-F5Session.ps1 index 3d5740f..1990ddd 100644 --- a/F5-LTM/Public/Test-F5Session.ps1 +++ b/F5-LTM/Public/Test-F5Session.ps1 @@ -7,11 +7,11 @@ Function Test-F5Session { param ( $F5Session=$Script:F5Session ) - #Validate F5Session - If ($($F5Session.BaseURL) -ne ("https://$($F5Session.Name)/mgmt/tm/ltm/") -or ($F5Session.WebSession.GetType().name -ne 'WebRequestSession')) { + #Validate F5Session + If ($($F5Session.BaseURL) -ne ("https://$($F5Session.Name)/mgmt/tm/ltm/") -or ($F5Session.WebSession.GetType().name -ne 'WebRequestSession')) { Write-Error ("BaseURL : $($F5Session.BaseURL)") Write-Error ("WebSession : $F5Session.WebSession.GetType().name") - Write-Error 'You must either create an F5 Session with script scope (by calling New-F5Session with -passthrough parameter) or pass an F5 session to this function.' + Write-Error 'You must either create an F5 Session with script scope (by calling New-F5Session with -passthrough parameter) or pass an F5 session to this function.' } # JN: Currently this function returns nothing if successful, which doesn't seem correct. However, if it returned true, all functions that call it would need to suppress the returned value # Else { diff --git a/F5-LTM/Public/Test-Functionality.ps1 b/F5-LTM/Public/Test-Functionality.ps1 index 21efeb4..1cb4a75 100644 --- a/F5-LTM/Public/Test-Functionality.ps1 +++ b/F5-LTM/Public/Test-Functionality.ps1 @@ -78,7 +78,7 @@ Set-PoolMemberDescription -F5Session $F5Session -Address $PoolMemberAddress -PoolName $TestPool -Description 'My new pool' | out-null Write-Host "New description:" Get-PoolMember -F5Session $F5Session -Address $PoolMemberAddress -PoolName $TestPool | Select-Object -ExpandProperty Description - + Write-Host "`r`n* Enable the new pool member" -ForegroundColor $TestNotesColor Enable-PoolMember -F5Session $F5Session -Address $PoolMemberAddress -PoolName $TestPool diff --git a/F5-LTM/Public/Test-HealthMonitor.ps1 b/F5-LTM/Public/Test-HealthMonitor.ps1 index 7bb2c61..2925e20 100644 --- a/F5-LTM/Public/Test-HealthMonitor.ps1 +++ b/F5-LTM/Public/Test-HealthMonitor.ps1 @@ -16,7 +16,7 @@ [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [string]$Partition, - + [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [string]$Type )