title: Using Invoke-Command to run Start-Process in an elevated session
body: <p>As a precursor to running an installation file on several remote servers, I need to update the Powershell setting <code>MaxMemoryPerShellMB</code>. This requires running a PS session as Administrator on the remote server. I have been trying to run <code>Invoke-Command</code> which then runs a ScriptBlock consisting of a <code>Start-Process</code> command which includes the <code>-Verb RunAs</code> parameter. Nothing seems to work, however.</p>
  
  <p>I have tried with various quoting schemes, single, double, triple, but nothing seems to work. </p>
  
  <p>I've tried running the <code>Start-Process</code> from an <code>Enter-PSSession</code>, with the same results.</p>
  
  <p>Following is the code I'm testing now:</p>
  
  <pre><code>$creds = Get-Credential -Username 'DOMAIN\userID' -Message "Enter Username and Password to access the remote servers."
  
  $ScriptBlock = {
      Start-Process -FilePath Powershell.exe -ArgumentList """Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024""" -Verb RunAs -Wait 
  }
  Invoke-Command -ComputerName testsvr01 -Credential $creds -ScriptBlock $ScriptBlock
  </code></pre>
  
  <p>I should be able to RDP to the remote server and run <code>Get-Item WSMan:\localhost\Shell</code> and have it show the updated value, but the value isn't changed.</p>
  
  <p>When running the code it pauses for a second when the <code>Invoke-Command</code> runs, but other than that, there is no feedback in Powershell.</p>
  
  <p>On the remote server I see the following two Kerberos errors in the System Event log.</p>
  
  <p><code>0x19 KDC_ERR_PREAUTH_REQUIRED</code>,</p>
  
  <p><code>0xd  KDC_ERR_BADOPTION</code></p>
  
  <p>Any help is greatly appreciated.</p>