PowerShell
  • Introduction
  • Chapter1: Write a basic powershell script
    • 1.1.Parameters
  • Chapter2: Remote controlling
    • 2.1.Introduction
    • 2.2.System Requirement
    • 2.3.Environment Setting
    • 2.4.Remote login
    • 2.5.Run remote program
    • 2.6.Remote interaction patterns
  • Chapter3: Some remote interactions for Windows 7\/ 10
    • 3.1.USB throughtput interactions
    • 3.2.mSATA throughtput interactions
    • 3.3.UART-echo interactions
    • 3.4.UART-throughput interactions
    • 3.5.UART-loopback interactions
    • 3.6.Ethernet-IIS interactions
    • 3.7.Ethernet-Wake on LAN interactions
    • 3.8.Ethernet-throughput interactions
    • 3.9.Ethernet-static ip interactions
    • 3.10.Ethernet-VPN interactions
    • 3.11.run once interactions
    • 3.12.Time zone interactions
    • 3.13.Firewall interactions
    • 3.14.Watchdog interactions
    • 3.15.File System interactions
    • 3.16.NTP interactions
    • 3.17.SNMP interactions
    • 3.18.FBWF interactions
    • 3.19.EWF interactions
    • 3.20.UWF interactions
  • Chapter4: Common Type
  • Chapter5: Common Operation
  • Chapter6: Socket Programming
Powered by GitBook
On this page

Was this helpful?

  1. Chapter3: Some remote interactions for Windows 7\/ 10

3.8.Ethernet-throughput interactions

Previous3.7.Ethernet-Wake on LAN interactionsNext3.9.Ethernet-static ip interactions

Last updated 5 years ago

Was this helpful?

  • Sequence Diagram

  • Programming

    • 1.iperf UDP server

              $p = Start-Process -FilePath "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe" -ArgumentList "-s -u -w 256k"
              #echo  $p
              $id=(get-process iperf).Id
              Wait-Process -id $id -timeout ($timeout_iperf +20)
      
              $iperf = Get-Process iperf -ErrorAction SilentlyContinue
              if ($iperf) {
                taskkill /T /F /PID $id
              }
    • 2.iperf UDP client

              $_bandwidth=$bandwidth+"M"  
              $pinfo = New-Object System.Diagnostics.ProcessStartInfo
              $pinfo.FileName = "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe" 
              $pinfo.Arguments="-u -c $clientIP -t $timeout_iperf -i 1 -f 'm' -b $_bandwidth -w 256k"
              $pinfo.UseShellExecute = $false
              $pinfo.CreateNoWindow = $true
              $pinfo.RedirectStandardOutput = $true
              $p = New-Object System.Diagnostics.Process
              $p.StartInfo = $pinfo
              $p.Start() | Out-Null
              $p.WaitForExit()
              $stdout = $p.StandardOutput.ReadToEnd()
    • 3.iperf TCP server

              $p = Start-Process -FilePath "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe" -ArgumentList "-s -w 256k"
              $id=(get-process iperf).Id
              Wait-Process -id $id -timeout ($timeout_iperf +20)
              $iperf = Get-Process iperf -ErrorAction SilentlyContinue
              if ($iperf) {
                taskkill /T /F /PID $id
              }
    • 4.iperf TCP client

            $pinfo = New-Object System.Diagnostics.ProcessStartInfo
            $pinfo.FileName = "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe"
            $pinfo.Arguments="-c $clientIP -t $timeout_iperf -i 1 -f 'm' -w 256k"
            $pinfo.UseShellExecute = $false
            $pinfo.CreateNoWindow = $true
            $pinfo.RedirectStandardOutput = $true
            $p = New-Object System.Diagnostics.Process
            $p.StartInfo = $pinfo
            $p.Start() | Out-Null
            $p.WaitForExit()
            $stdout = $p.StandardOutput.ReadToEnd()
  • 5.Change NIC speed & duplex mode

            Param (   
                         [parameter(mandatory=$False,HelpMessage='threshold for performane test')]      
                         [string]$computer
                         [parameter(mandatory=$False,HelpMessage='disk type for performane test')]     
                         [string]$speed = "1"     
             )  
          #"0" {$duplex = "Auto Detect"}            
          #"1" {$duplex = "10Mbps \ Half Duplex"}            
          #"2" {$duplex = "10Mbps \ Full Duplex"}            
          #"3" {$duplex = "100Mbps \ Half Duplex"}            
          #"4" {$duplex = "100Mbps \ Full Duplex"}     
          #"6" {$duplex = "1Gbps \ Full Duplex"}     

          #$computer = "192.168.31.22"
          #$speed = "1"
          $HKLM = 2147483650            
          $reg = [wmiclass]"\\$computer\root\default:StdRegprov"            
          $keyroot = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"            

          Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $computer -Filter "IPEnabled='$true'" |            
          foreach {            

              $data = $_.Caption -split "]"            
              $suffix = $data[0].Substring(($data[0].length-4),4)            
              $key = $keyroot + "\$suffix" 

              $value = "*SpeedDuplex"            
              $dup = $reg.SetStringValue($HKLM, $key, $value, $speed)  ## REG_SZ       

              $nic = $_.GetRelated("Win32_NetworkAdapter") | select Speed, NetConnectionId            

              netsh interface set interface $nic.NetConnectionID DISABLED  
              netsh interface set interface $nic.NetConnectionID ENABLED 
          }