From 388bad3a66a811759d0fef2ef298e9a99bb4cc88 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Wed, 8 Jan 2025 17:00:47 +0100 Subject: [PATCH] policy: Add dstinf for Add-FGTFIrewallPolicyMember --- PowerFGT/Public/cmdb/firewall/policy.ps1 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/PowerFGT/Public/cmdb/firewall/policy.ps1 b/PowerFGT/Public/cmdb/firewall/policy.ps1 index e2c7f21a..7bc7d78c 100644 --- a/PowerFGT/Public/cmdb/firewall/policy.ps1 +++ b/PowerFGT/Public/cmdb/firewall/policy.ps1 @@ -354,6 +354,8 @@ function Add-FGTFirewallPolicyMember { [Parameter(Mandatory = $false)] [string[]]$dstaddr, [Parameter(Mandatory = $false)] + [string[]]$dstintf, + [Parameter(Mandatory = $false)] [String[]]$vdom, [Parameter(Mandatory = $false)] [psobject]$connection = $DefaultFGTConnection @@ -430,6 +432,25 @@ function Add-FGTFirewallPolicyMember { $_policy | add-member -name "dstaddr" -membertype NoteProperty -Value $members } + if ( $PsBoundParameters.ContainsKey('dstintf') ) { + + if ($policy.dstintf.name -eq "all") { + #all => create new empty array members + $members = @() + } + else { + #Add member to existing source interface + $members = $policy.dstintf + } + + foreach ( $member in $dstintf ) { + $member_name = @{ } + $member_name.add( 'name', $member) + $members += $member_name + } + $_policy | add-member -name "dstintf" -membertype NoteProperty -Value $members + } + if ($PSCmdlet.ShouldProcess($policy.name, 'Add Firewall Policy Group Member')) { Invoke-FGTRestMethod -method "PUT" -body $_policy -uri $uri -uri_escape $policy.policyid -connection $connection @invokeParams | Out-Null