title: Running cmd.exe through start-process but unable to pass the command to cmd.exe
body: <p>I want to run a groovy script with <code>cmd.exe</code> under a different user.</p>
  
  <p>I have used <code>Start-Process</code>, when the script gets executed it just opens the prompt on the screen with different user but doesn't process the <code>$command</code>.</p>
  
  <p>So my question is "How to pass the command after running <code>cmd.exe</code> with PowerShell?</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>$username = "abc"
  $pwd = ConvertTo -SecureString "xyz" -AsPlainText -Force
  $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username $pw
  
  $command = "filepath/.groovy"
  
  try {
      Start-Process 'cmd' -Credential $cred -ArgumentList $command
      Write-Host $LASTEXITCODE
      if($LASTEXITCODE -ne 0) {
          throw "Error occured"
      } else {
          return 0
      }
  } catch {
      Write-Error "Error Desc:$_Error.InnerException.Message";
  }
  </code></pre>