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.5.Run remote program

  • 1.Run powershell script:

    • 1.use start-process

           $passwd = convertto-securestring -AsPlainText -Force -String $clientPassword
           $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $clientUser,$passwd
           $session = new-pssession -computername $clientIP -credential $cred
           Invoke-Command -Session $session -ScriptBlock {param($clientDrive, $clientShareFolder) Start-Process powershell.exe -ArgumentList "$clientDrive\$clientShareFolderfbwfDisableSetting.ps1" $clientDrive $clientShareFolder}  -Args $clientDrive, $clientShareFolder
    • 2.Not use start-process

      • In some condition, it will cause computer to hang on when remote using "start-process", so do not use start-process, for example:

         $passwd = convertto-securestring -AsPlainText -Force -String $clientPassword
         $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $clientUser,$passwd
         $session = new-pssession -computername $clientIP -credential $cred
         Invoke-Command -Session $session -ScriptBlock {param($clientDrive, $clientShareFolder) cd "$clientDrive\$clientShareFolder"}  -Args $clientDrive, $clientShareFolder
         Invoke-Command -Session $session -ScriptBlock {.\fbwfDisableSetting.ps1 $clientDrive $clientShareFolder}  
  • 2.Run .exe:

    • ex:

       bat2 ="RunOnce.exe"
       $executeFile2 = "$clientDrive\$clientShareFolder\$bat2"
       $arguments="noticestart $clientDrive\$clientShareFolder\psrmenable.bat"
       Invoke-Command -Session $session -ScriptBlock {param($executeFile2,$arguments) Start-Process -FilePath 
Previous2.4.Remote loginNext2.6.Remote interaction patterns

Last updated 5 years ago

Was this helpful?