# Create the logs directory if it doesn't already exist if (-not (Test-Path -PathType Container 'C:\Program Files\iperf3\logs')) { New-Item -ItemType Directory -Path 'C:\Program Files\iperf3\logs' | Out-Null } $Service = Get-Service -Name iperf3server -ErrorAction SilentlyContinue if ($null -eq $Service) { & "C:\Program Files\nssm\win64\nssm.exe" install iperf3server "C:\Program Files\iperf3\iperf3.exe" "--server --port 5201 --format m --verbose" & "C:\Program Files\nssm\win64\nssm.exe" set iperf3server DisplayName "iPerf3 Server" | Out-Null & "C:\Program Files\nssm\win64\nssm.exe" set iperf3server Description "iPerf3 is a tool for active measurements of the maximum achievable bandwidth on IP networks." | Out-Null & "C:\Program Files\nssm\win64\nssm.exe" set iperf3server AppStdout "C:\Program Files\iperf3\logs\service.log" | Out-Null & "C:\Program Files\nssm\win64\nssm.exe" set iperf3server AppStderr "C:\Program Files\iperf3\logs\service.log" | Out-Null Write-Host "Starting service..." Start-Service -Name iperf3server } else { Write-Host "Service is already installed." }