{"id":6295,"date":"2022-10-25T05:47:57","date_gmt":"2022-10-25T05:47:57","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=6295"},"modified":"2022-11-23T00:42:34","modified_gmt":"2022-11-23T00:42:34","slug":"iperf-rmm-automation-powershell","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/iperf-rmm-automation-powershell","title":{"rendered":"iPerf RMM Automation Powershell"},"content":{"rendered":"<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">###<br\/># Author: Dave Long &lt;dlong@cagedata.com&gt;<br\/># Gets an bandwidth test using iPerf3. Sum is the download speed of computer.<br\/>###<br\/><br\/>$client = &quot;TAUL7053&quot;<br\/>$iPerfDownload = &quot;https:\/\/iperf.fr\/download\/windows\/iperf-3.1.3-win64.zip&quot;<br\/>$psexecDownload = &quot;https:\/\/download.sysinternals.com\/files\/PSTools.zip&quot;<br\/>$iperfDownloadLocation = Join-Path $env:TEMP &quot;iperf.zip&quot;<br\/>$psxecDownloadLocation = Join-Path $env:TEMP &quot;PSTools.zip&quot;<br\/>$iPerfPath = Join-Path $env:TEMP &quot;iperf&quot;<br\/>$psexecPath = Join-Path $env:TEMP &quot;PSTools&quot;<br\/><br\/>#download and extract iPerf<br\/>if (!(Test-Path $iPerfPath)) {<br\/>  Invoke-WebRequest -Uri $iPerfDownload -OutFile $iperfDownloadLocation<br\/>  Expand-Archive -Path $iperfDownloadLocation -DestinationPath $iPerfPath<br\/>}<br\/><br\/>#download and extract psexec<br\/>if (!(Test-Path $psexecPath)) {<br\/>  Invoke-WebRequest -Uri $psexecDownload -OutFile $psxecDownloadLocation<br\/>  Expand-Archive -Path $psxecDownloadLocation -DestinationPath $psexecPath<br\/>}<br\/><br\/><br\/>#create temp directory<br\/>#null to stop output<br\/>$null = New-Item -Path \\\\$client\\c$\\Temp -type directory -Force <br\/><br\/>Set-Location (Join-Path $iPerfPath &quot;iperf-3.1.3-win64&quot;)<br\/><br\/>#copy iperf3 to client temp<br\/>Copy-Item -Path &#039;iperf3.exe&#039; -Destination \\\\$client\\c$\\Temp<br\/>Copy-Item -Path &#039;cygwin1.dll&#039; -Destination \\\\$client\\c$\\Temp<br\/><br\/><br\/>#start iperf server for download<br\/>#You can use -P option for limiting the incoming clients. For example if you run iperf -s -P 1 command, after the client finishes the test, the server shuts itself down.<br\/>Start-Process -Filepath &quot;$psexecPath\\psexec.exe&quot; -ArgumentList &quot;\\\\$client c:\\Temp\\iperf3.exe -s -1&quot;<br\/><br\/>#Wait to get iperfstartedonServer<br\/>Start-Sleep -Seconds 30<br\/><br\/>Write-Host &quot;Starting Download Test&quot;<br\/>$Download = &amp; .\\iperf3.exe --client $client -P 10 -t 60 -w 3M<br\/>if (($Download | Select-Object -Last 1) -eq &quot;iperf Done.&quot;) {<br\/>  $sender = $Download | Select-Object -Last 4 | Select-Object -First 2 | Select-Object -First 1<br\/>  $sender = [regex]::Matches($sender, &#039;\\d+\\sMbits[\/]sec&#039;).Value<br\/>  $sender = $sender -replace &quot; Mbits\/sec&quot;,&quot;&quot;<br\/>  #in Mbits\/sec<br\/>  $sender<br\/>  <br\/>  $receiver = $Download | Select-Object -Last 4 | Select-Object -First 2 | Select-Object -Last 1 <br\/>  $receiver = [regex]::Matches($receiver, &#039;\\d+\\sMbits[\/]sec&#039;).Value<br\/>  $receiver = $receiver -replace &quot; Mbits\/sec&quot;,&quot;&quot;<br\/>  #in Mbits\/sec<br\/>  $receiver<br\/>} else {<br\/>  Write-Host &quot;iPerf failed to get download speed.&quot;<br\/>}<\/code><\/pre> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">iPerf RMM Automation Powershell<\/span> <\/div> <\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3904,4053],"class_list":["post-6295","post","type-post","status-publish","format-standard","hentry","category-research","tag-iperf","tag-rmm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=6295"}],"version-history":[{"count":4,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6295\/revisions"}],"predecessor-version":[{"id":6361,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/6295\/revisions\/6361"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=6295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=6295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=6295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}