Skip to content

Commit

Permalink
Policy(RemoveMember): Fix example and error
Browse files Browse the repository at this point in the history
Oups...
  • Loading branch information
alagoutte committed Jan 14, 2025
1 parent af880d6 commit 12ca55b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions PowerFGT/Public/cmdb/firewall/policy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1019,16 +1019,16 @@ function Remove-FGTFirewallPolicyMember {
Remove a FortiGate Policy Member (source or destination address/interface)
.EXAMPLE
$MyFGTPolicy = Get-FGTFirewallPolicyGroup -name MyFGTPolicy
PS C:\>$MyFGTPolicy | Remove-FGTFirewallPolicyGroupMember -member MyAddress1
$MyFGTPolicy = Get-FGTFirewallPolicy -name MyFGTPolicy
PS C:\>$MyFGTPolicy | Remove-FGTFirewallPolicyMember -srcaddr MyAddress1
Remove MyAddress1 member to MyFGTPolicy
Remove source MyAddress1 member to MyFGTPolicy
.EXAMPLE
$MyFGTPolicy = Get-FGTFirewallPolicyGroup -name MyFGTPolicy
PS C:\>$MyFGTPolicy | Remove-FGTFirewallPolicyGroupMember -member MyAddress1, MyAddress2
$MyFGTPolicy = Get-FGTFirewallPolicy -name MyFGTPolicy
PS C:\>$MyFGTPolicy | Remove-FGTFirewallPolicyMember -dstaddr MyAddress1, MyAddress2
Remove MyAddress1 and MyAddress2 member to MyFGTPolicy
Remove destination MyAddress1 and MyAddress2 member to MyFGTPolicy
.EXAMPLE
$MyFGTPolicy = Get-FGTFirewallPolicy -name MyFGTPolicy
Expand Down Expand Up @@ -1094,7 +1094,7 @@ function Remove-FGTFirewallPolicyMember {

#check if there is always a member... (it is not really (dependy of release...) possible don't have member on Policy)
if ( $members.count -eq 0 ) {
Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Address Group"
Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Source Address"
}

#if there is only One or less member force to be an array
Expand Down Expand Up @@ -1122,7 +1122,7 @@ function Remove-FGTFirewallPolicyMember {

#check if there is always a member... (it is not really (dependy of release...) possible don't have member on Policy)
if ( $members.count -eq 0 ) {
Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Address Group"
Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Destination Address"
}

#if there is only One or less member force to be an array
Expand Down
4 changes: 2 additions & 2 deletions Tests/integration/FirewallPolicy.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ Describe "Remove Firewall Policy Member" {
It "Try Remove 3 members to Policy Src Address $pester_address1, $pester_address2, $pester_address3 (with 3 members before)" {
{
Get-FGTFirewallPolicy -Name $pester_policy1 | Remove-FGTFirewallPolicyMember -srcaddr $pester_address1, $pester_address2, $pester_address3
} | Should -Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Address Group"
} | Should -Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Source Address"
}

}
Expand Down Expand Up @@ -1870,7 +1870,7 @@ Describe "Remove Firewall Policy Member" {
It "Try Remove 3 members to Policy Dst Address $pester_address1, $pester_address2, $pester_address3 (with 3 members before)" {
{
Get-FGTFirewallPolicy -Name $pester_policy1 | Remove-FGTFirewallPolicyMember -dstaddr $pester_address1, $pester_address2, $pester_address3
} | Should -Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Address Group"
} | Should -Throw "You can't remove all members. Use Set-FGTFirewallPolicy to remove Destination Address"
}

}
Expand Down

0 comments on commit 12ca55b

Please sign in to comment.