title: Running PowerShell script on a remote machine using PSTool
body: <p>I need to run a PS script on a remote machine, am doing as in the below code.</p>
  
  <pre><code>Process psExecer = new Process
              {
                  StartInfo =
                  {
                      UseShellExecute = false,
                      CreateNoWindow = false,
                      WindowStyle = ProcessWindowStyle.Hidden,
                      FileName = @"c:\PsTools\PsExec.exe",
                      Arguments = @"c:\windows\System32\cmd.exe /k  c:\windows\System32\WindowsPowerShell\v1.0\powershell.exe E:\Scripts\SetUP.ps1 -u super -p Pass -s"        
                  }
              };
  
              psExecer.Start();
              psExecer.WaitForExit();
              Thread.Sleep(5000);  
  </code></pre>
  
  <p>problem is that script has some sharepoint cmdlets and it has to load sharepoint PSSnapin. Script runs properly only when its run in 64 bit image of Powershell.</p>
  
  <p>When i tried to run using PSTool, PSTool always ends up invoking 32 bit PowerShell from %windir%\SysWoW64 folder, even when i explicitly mentioned the path as shown in the code.</p>
  
  <p>Why is it so, what is the solution to my problem</p>
  
  <p>Regards,
  Jeez</p>