Skip to content

Commit

Permalink
fix: new-localinpolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTaylorLee committed Apr 3, 2024
1 parent 9054e10 commit aa6840e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 2 additions & 1 deletion modules/AdminToolbox.FortiWizard/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,5 @@
* **2.18.42** CI Maintenance Release
* **2.18.43** CI Maintenance Release
* **2.18.44** CI Maintenance Release
* **2.18.45** CI Maintenance Release
* **2.18.45** CI Maintenance Release
* **2.18.46** Fix new-localinpolicy address objects inserting the cidr twice into address object names
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#Required By Function
#New-LocalInPolicy

Function New-LocalInAddressObject {

[CmdletBinding()]
Param (
[Parameter(Mandatory = $true)]$AddressName,
[Parameter(Mandatory = $true)]
[ValidateScript( {
if ($_ -match '^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[/]{1}[0-9]{1,2}$') {
$true
}
else {
throw "$_ is an invalid pattern. You must provide a proper CIDR format. ex: 192.168.0.0/24"
}
})]
$CIDR
)

$calc = Invoke-PSipcalc $cidr
$IPAddress = ($calc).IP
$SubnetMask = ($calc).SubnetMask

Write-Output "
config firewall address
edit ""$AddressName""
set subnet $IPAddress $SubnetMask
set allow-routing enable
next
end"
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function New-LocalinPolicy {
}

Foreach ($Address in $Addresses) {
New-AddressObject -AddressName $Address.Name -CIDR $Address.CIDR
New-LocalInAddressObject -AddressName $Address.Name -CIDR $Address.CIDR
}

#Create Address Objects for the policy
Expand Down

0 comments on commit aa6840e

Please sign in to comment.