Public/Invoke-LissWindowsIperfTest.ps1
|
function Invoke-LissWindowsIperfTest { <# .SYNOPSIS Runs an approved, bounded iperf3 throughput test. .DESCRIPTION Uses the bundled signed iperf3 client or an explicitly selected approved executable against an approved server. The module never installs system software or selects a public server. JSON output is parsed and returned as a structured object. This operation consumes bandwidth and requires -Approved plus ShouldProcess confirmation. .PARAMETER Server Approved iperf3 server hostname or address. .PARAMETER Port Approved iperf3 server port. .PARAMETER Direction Upload sends from this endpoint; Download requests iperf3 reverse mode. .PARAMETER DurationSeconds Test duration, from 1 through 120 seconds. .PARAMETER IperfPath Optional path to another approved iperf3 executable. The signed bundled x64 client is used by default. .PARAMETER Approved Confirms that the named server and bandwidth use are approved. .EXAMPLE Invoke-LissWindowsIperfTest -Server iperf.internal.example -Direction Upload -DurationSeconds 10 -Approved -Confirm:$false #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')] [OutputType('LISSTech.WindowsNetworkDiagnostics.IperfResult')] param( [Parameter(Mandatory)][ValidatePattern('^[a-zA-Z0-9][a-zA-Z0-9._:-]*$')][string]$Server, [ValidateRange(1, 65535)][int]$Port = 5201, [ValidateSet('Upload', 'Download')][string]$Direction = 'Upload', [ValidateRange(1, 120)][int]$DurationSeconds = 10, [string]$IperfPath, [Parameter(Mandatory)][switch]$Approved ) if (-not $Approved) { throw 'Explicit -Approved confirmation is required for throughput testing.' } $executable = Resolve-LissIperfExecutable -Path $IperfPath $target = "$Direction throughput to approved server $Server`:$Port for $DurationSeconds seconds" if (-not $PSCmdlet.ShouldProcess($target, 'Run iperf3 bandwidth test')) { return } $started = Get-Date $iperf = Invoke-LissIperfProcess -Executable $executable -Server $Server -Port $Port -DurationSeconds $DurationSeconds -Direction $Direction [pscustomobject]@{ PSTypeName = 'LISSTech.WindowsNetworkDiagnostics.IperfResult' Server = $Server Port = $Port Direction = $Direction DurationSeconds = $DurationSeconds StartedAt = $started CompletedAt = Get-Date IperfPath = $executable Arguments = $iperf.Arguments Result = $iperf.Result ErrorText = $iperf.ErrorText } } |