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. Chapter2: Remote controlling

2.3.Environment Setting

Previous2.2.System RequirementNext2.4.Remote login

Last updated 5 years ago

Was this helpful?

  • Procedure

    • Initialize -> Enable -> During testing

  • 1.Initialize:

    • 1.Create a account/ Password for DUT, that's important

      • if you did not create password, you will not be allowed to Enable-PSRemoting.

    • 2.Enable powershell script for Windows

       %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -command  "Set-ExecutionPolicy unrestricted -force"
    • 3.Setting network environment:

      • Attach Ethernet and Set a Static IP.

      • Turn off firewall or add rule to enable remote control.

         netsh advfirewall set allprofiles state off
      • Change connection type to private or work connection, otherwise you will not be allowed to Enable-PSRemoting.

             $NLMType = [Type]::GetTypeFromCLSID('DCB00C01-570F-4A9B-8D69-199FDBA5723B')
               $INetworkListManager = [Activator]::CreateInstance($NLMType)
               $NLM_ENUM_NETWORK_CONNECTED  = 3
               $NLM_NETWORK_CATEGORY_PUBLIC = 0x00
               $NLM_NETWORK_CATEGORY_PRIVATE = 0x01
               $UNIDENTIFIED = "Unidentified network"
               $INetworks = $INetworkListManager.GetNetworks($NLM_ENUM_NETWORK_CONNECTED)
        
                foreach ($INetwork in $INetworks)
                {
                    $Name = $INetwork.GetName()
                    $Category = $INetwork.GetCategory()
        
                    if (($Category -eq $NLM_NETWORK_CATEGORY_PUBLIC) )
                    {
                        $INetwork.SetCategory($NLM_NETWORK_CATEGORY_PRIVATE)
                    }
                }
    • 4.Enable Powershell Remote ability :

        %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -command "Enable-PSRemoting -Force"
    • 5.Check details again before remote control :

          cd wsman::localhost\client 
          Set-Item TrustedHosts *  -force
          Restart-Service WinRm
          cd c:\windows\system32
          Set-PSSessionConfiguration  -Name Microsoft.PowerShell -force
          winrm quickconfig -quiet
      
          Enable-PSRemoting -Force
          set-executionpolicy unrestricted -force
          set-executionpolicy allsigned -force
          set-executionpolicy remotesigned -force
    • 6.Set auto login if you need:

          REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
          REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d %1 /f
          REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d %2 /f
          REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d %3 /f
    • 7.Enable Powershell Remote ability every time login to desktop if you need:

    • 8.Make sure that the DUT can be login:

    • Summary:

      • All we have to do to initialize remote control:

        • 1.Make sure that account/ password were valid

        • 2.Make sure that ethernet was attatched

        • 3.Make sure that IP is valid or not

        • 4.Run scripts

  • 2.Enable:

    • Summary:

      • All we have to do to initialize remote control:

        • 1.Make sure that account/ password were valid

        • 2.Make sure that ethernet was attatched

        • 3.Make sure that IP is valid or not

        • 4.Run scripts

          %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -command "Enable-PSRemoting -Force"
  • 3.During testing

    • Something need to notice:

      • 1.You must let computer auto login if the computer needs to reboot during testing

           REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
           REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultDomainName /t REG_SZ /d %1 /f
           REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d %2 /f
           REG ADD "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d %3 /f
      • 2.The computer need to enable remote control every time log in to the desktop