Public/New-AddressObject.ps1

Function New-AddressObject {
    <#
    .Description
    Create a New Address Object
 
    .Parameter AddressName
    Specify a Unique name for the Address Object
 
    .Parameter IPAddress
    Specify a IPAddress that will be ranged by the subnet mask
 
    .Parameter SubnetMask
    Specify a SubnetMask for the IPAddress
 
    .Example
    $Params = @{
    AddressName = "ComanyLan_192.168.0.1/26"
    IPAddress = "192.168.0.1"
    SubnetMask = "255.255.255.192"
    }
 
    New-AddressObject @params
 
    .Link
    https://github.com/TheTaylorLee/AdminToolbox/tree/master/docs
    #>


    [CmdletBinding()]
    Param (
        [Parameter(Mandatory = $true)]$AddressName,
        [Parameter(Mandatory = $true)][ValidatePattern('^[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}[.]{1}[0-9]{1,3}$')]$IPAddress,
        [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}$') {
                    $true
                }
                else {
                    throw "$_ is an invalid pattern. You must provide a subnet mask and not a prefix."
                }
            })]$SubnetMask
    )

    Write-Output "
#Create Addresses
 
config firewall address
    edit ""$AddressName""
        set subnet $IPAddress $SubnetMask
        set allow-routing enable
    next
end
"

}