Skip to content

Commit

Permalink
Add Get-FGTMonitorSystemInterfaceDHCPStatus (#264)
Browse files Browse the repository at this point in the history
* Add Get-FGTMonitorSystemInterfaceDHCPStatus

---------

Co-authored-by: Cédric Moreau <[email protected]>
  • Loading branch information
CedricMoreau and Cédric Moreau authored Dec 10, 2024
1 parent 78e7599 commit 3c5ac38
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
47 changes: 47 additions & 0 deletions PowerFGT/Public/monitor/system/interface/dhcp-status.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Copyright 2024, Cedric Moreau <moreaucedric0 at gmail dot com>
#
# SPDX-License-Identifier: Apache-2.0
#
function Get-FGTMonitorSystemInterfaceDHCPStatus {

<#
.SYNOPSIS
Get Interface DHCP Status
.DESCRIPTION
Get Client DHCP Status for an interface
.EXAMPLE
Get-FGTMonitorSystemInterfaceDHCPStatus -interface wan
Get DHCP Client status for the specified interface wan
#>

Param(
[Parameter (Mandatory = $true, Position = 1)]
[string]$interface,
[Parameter(Mandatory = $false)]
[String[]]$vdom,
[Parameter(Mandatory = $false)]
[psobject]$connection = $DefaultFGTConnection
)

Begin {
}

Process {

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

$uri = "api/v2/monitor/system/interface/dhcp-status?mkey=$($interface)"
$response = Invoke-FGTRestMethod -uri $uri -method 'GET' -connection $connection
$response.results
}

End {
}
}
3 changes: 3 additions & 0 deletions Tests/integration/Connection.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ Describe "Connect to a FortiGate (using multi connection)" {
It "Use Multi connection for call Get Monitor System HA Checksum (< 6.2.0 with no HA)" -skip:( -Not $VersionIs60WithNoHA) {
{ Get-FGTMonitorSystemHAChecksum -connection $fgt } | Should -Throw "You can't check HA Checksum with FortiOS < 6.2.0"
}
It "Use Multi connection for call Get Monitor System Interface DHCP Status" {
{ Get-FGTMonitorSystemInterfaceDHCPStatus -interface $pester_port1 -connection $fgt } | Should -Not -Throw
}
It "Use Multi connection for call Get Monitor License Status" {
{ Get-FGTMonitorLicenseStatus -connection $fgt } | Should -Not -Throw
}
Expand Down

0 comments on commit 3c5ac38

Please sign in to comment.