Public/Start-Iperf.ps1

function Start-Iperf {
    <#
    .SYNOPSIS
    -Taylor Lee
    Modified 06262019
    .DESCRIPTION
    Setup and iperf server or client connection for testing connection speeds
 
    .EXAMPLE
    Setup a iperf server connection
 
    Start-Iperf -server -port 10555
 
    .EXAMPLE
    Initiate a client bandwidth test
 
    Start-Iperf -client -serverip 0.0.0.0 -port 10555
 
    .EXAMPLE
    Initiate a client bandwidth test
 
    Start-Iperf -Client -serverip 0.0.0.0 --port 10555 udp
    #>


    [CmdletBinding()]
    Param (

        [Parameter(Mandatory = $true, ParameterSetName = 'Server')][Switch]$server,
        [Parameter(Mandatory = $true, ParameterSetName = 'Client')][switch]$client,
        [Parameter(Mandatory = $false, ParameterSetName = 'Client')][Switch]$udp,
        [Parameter(Mandatory = $true, ParameterSetName = 'Client')]$serverip,
        [Parameter(Mandatory = $true, ParameterSetName = 'Client')]
        [Parameter(Mandatory = $true, ParameterSetName = 'Server')]
        $port
    )

    $AdminConsole = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")

    if ($AdminConsole -like "False*") {
        Write-Warning "You need to run Powerhsell as an admin to use this function!"
        Break
    }

    if ($server) {
        iperf3.exe -s -p $port
    }

    if ($client) {
        if ($udp) {
            iperf3.exe -c $serverip -p $port -u -b 0
        }

        else {
            iperf3.exe -c $serverip -p $port
        }
    }
}