title: How to run commands on a remote computer using PSExec and PowerShell?
body: <p>I am trying to install an .exe program remotely to many workstations in the domain.</p>
  
  <p>The command I am trying to run in the remote computer's PowerShell instance:</p>
  
  <pre><code>.\PsExec.exe \\$Computer /s cmd /c %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File \\FileShare\Software\DellSupportAssist.ps1
  </code></pre>
  
  <p>And the script I am calling in the command above:</p>
  
  <pre><code> #Retrieves a list of computers in AD.
  $Computers = Get-ADComputer -Filter 'Name -like "Workstation*"' | Select-Object -ExpandProperty Name
  
  ForEach ($Computer in $Computers) {
  #Opens a remote session into the computer.
  .\PsExec.exe C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe \\$Computer
  
  #Installs Dell SupportAssist for each computer
  Invoke-WebRequest -Uri "https://downloads.dell.com/serviceability/catalog/SupportAssistInstaller.exe" -OutFile "C:\Users\$env:Username\Downloads\SupportAssistInstaller.exe"
  Start-Process "C:\Users\$env:Username\Downloads\SupportAssistInstaller.exe" -ArgumentList "/q" -Wait -NoNewWindow
  Write-Host "Installing Dell SupportAssist on $Computer" -ForegroundColor Green
  
  #Checks whether Dell SupportAssist was successfully installed or not
  if (Get-WmiObject -Class win32_product -ComputerName $Computer | Where {$_.Name -match "Dell Support*"} | Select-Object -ExpandProperty Name) {
      Write-Host "Dell SupportAssist was successfully installed on $Computer" -ForegroundColor Yellow
      } else {
      Write-Host "Dell SupportAssist was not successfully installed on $Computer" -ForegroundColor Red
      }
  
  exit
  </code></pre>
  
  <p>}</p>
  
  <p>I am having the following issues:</p>
  
  <ul>
  <li>'Target name incorrect' (for half of the computers in the domain.)</li>
  <li>.\PsExec.exe : The term '\FileShare\Software\DellSupportAssist.ps1' is not recognized as the name of a cmdlet, function, script file, or operable (for the computers I can connect to in the domain)</li>
  </ul>