title: Powershell - Start-Process to launch hello world is not working
body: <p>I am trying to figure out how to run powershell script with elevated credentials, and was told the best way to do this was with Start-Process</p>
  
  <p>And this website, <a href="http://social.technet.microsoft.com/Forums/windowsserver/en-US/132e170f-e3e8-4178-9454-e37bfccd39ea/startprocess-verb-runas-credential" rel="nofollow">http://social.technet.microsoft.com/Forums/windowsserver/en-US/132e170f-e3e8-4178-9454-e37bfccd39ea/startprocess-verb-runas-credential</a> is also good reference</p>
  
  <p>But I am still having trouble.</p>
  
  <p>I created one script for testing purposes, hello.ps1 </p>
  
  <pre><code>write-host Hello World
  </code></pre>
  
  <p>That runs well by itself</p>
  
  <p>Then, I created another script to invoke Hello World with elevated credentials</p>
  
  <pre><code>&lt;#Previously created password file in C:\Script\cred.txt, read-host -assecurestring | convertfrom-securestring | out-file C:\Script\cred.txt#&gt;
  
  $password = get-content C:\Script\cred.txt | convertto-securestring
  $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "DOMAIN\Username",$password
  $script = "C:\script\hello.ps1"
  Start-Process powershell -Credential $credentials -verb runas -ArgumentList "-file $script"
  </code></pre>
  
  <p>And I get error:</p>
  
  <pre><code>At C:\script\my_script.ps1:6 char:14
  + Start-Process &lt;&lt;&lt;&lt;  powershell -Credential $credentials -verb runas -ArgumentList "-file $script"
      + CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
      + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.StartProcessCommand
  </code></pre>
  
  <p>EDIT</p>
  
  <p>@Adi Inbar</p>
  
  <p>I updated the code as follows</p>
  
  <pre><code>$password = get-content C:\Script\cred.txt | convertto-securestring
  $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "DOMAIN\Username",$password
  $script = "C:\Script\hello.ps1"
  Start-Process powershell -Credential $credentials  -ArgumentList "-file $script"
  </code></pre>
  
  <p>But now a cmd windows pops up and the output is blank, instead of the expected "Hello World"</p>
  
  <p>EDIT</p>
  
  <p>And I read that you must include -FilePath if you include -Credential, but code is still not working :-( </p>
  
  <p>It just pops-up the cmd window and no output is written in powershell_ise.exe GUI</p>
  
  <pre><code>&lt;#Previously created password file in C:\Script\cred.txt, read-host -assecurestring | convertfrom-securestring | out-file C:\Script\cred.txt#&gt;
  
  $password = get-content C:\Script\cred.txt | convertto-securestring
  $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "DOMAIN\Username",$password
  $script = "C:\Script\hello.ps1"
  Start-Process -FilePath C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Credential $credentials -ArgumentList "-file $script"
  </code></pre>