Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Get-FGTMonitorFirewallAddressFQDN #275

Merged
merged 4 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions PowerFGT/Public/monitor/firewall/address-fqdn.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# Copyright 2022, Alexis La Goutte <alexis dot lagoutte at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#
function Get-FGTMonitorFirewallAddressFQDN {

<#
.SYNOPSIS
Get Monitor Firewall Address FQDN

.DESCRIPTION
Get Monitor Firewall Adresss FQDN (fqdn, addrs, addrs_count...)

.EXAMPLE
Get-FGTMonitorFirewallAddressFQDN

Get ALL Firewall Address FQDN

.EXAMPLE
Get-FGTMonitorFirewallAddressFQDN -fqdn github.com

Get Firewall Address FQDN of github.com

.EXAMPLE
Get-FGTMonitorFirewallAddressFQDN -vdom vdomX

Get Firewall Address FQDN of vdomX

#>

Param(
[Parameter (Mandatory = $false, Position = 1)]
[string]$fqdn,
[Parameter (Mandatory = $false)]
[switch]$skip,
[Parameter(Mandatory = $false)]
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)

Begin {
}

Process {

$invokeParams = @{ }
if ( $PsBoundParameters.ContainsKey('skip') ) {
$invokeParams.add( 'skip', $skip )
}
if ( $PsBoundParameters.ContainsKey('vdom') ) {
$invokeParams.add( 'vdom', $vdom )
}

$uri = 'api/v2/monitor/firewall/address-fqdns?'

if ($fqdn) {
$uri += "mkey=$($fqdn)"
}

$response = Invoke-FGTRestMethod -uri $uri -method 'GET' -connection $connection @invokeParams
$response.results
}

End {
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ You need to have VPN IPsec Interface Phase 1 created before

It is possible to `monitor` FortiGate

* `Get-FGTMonitorFirewallAddressFQDN` List of FQDN address objects and the IPs they resolved to
* `Get-FGTMonitorFirewallPolicy` List traffic statistics for firewall policies
* `Get-FGTMonitorFirewallSession` List all active firewall sessions
* `Get-FGTMonitorRouterIPv4` List all active IPv4 routing table entries
Expand Down
3 changes: 3 additions & 0 deletions Tests/integration/Connection.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ Describe "Connect to a FortiGate (using multi connection)" {
It "Use Multi connection for call Get Webfilter Profile" {
{ Get-FGTWebfilterProfile -connection $fgt } | Should -Not -Throw
}
It "Use Multi connection for call Get Monitor Firewall Address FQDN" {
{ Get-FGTMonitorFirewallAddressFQDN -connection $fgt } | Should -Not -Throw
}
It "Use Multi connection for call Get Monitor Firewall Policy" {
{ Get-FGTMonitorFirewallPolicy -connection $fgt } | Should -Not -Throw
}
Expand Down
Loading