title: how to execute set of commands in elevated mode of powershell
body: <p>i have tried the below way to execute the commands in administrator mode.</p>
  
  <p><code>PS&gt;start-process powershell -verb runas $app = Get-AppxPackage -all| Where-Object{$_.Name-like "*$ReleaseName*"}</code></p>
  
  <p><code>PS&gt;start-process powershell -verb runas Remove-AppxPackage $app.PackageFullName</code></p>
  
  <ul>
  <li>for the first call, it opens and executes the command successfully and closes the admin powershell instance. for the second call it requires $app information which is not available because it again opens a new PS admin window</li>
  <li>i can't execute <code>Get-AppxPackage -all</code> in normal mode <code>-all</code> requires admin mode only</li>
  </ul>
  
  <p>tried the below but no luck.</p>
  
  <pre><code>PS&gt;start-process powershell -verb runas 
  {
  
  $app = Get-AppxPackage | Where-Object{$_.Name-like "*$ReleaseName*"};
  
  Remove-AppxPackage $app.PackageFullName
  
  }
  </code></pre>
  
  <p>can someone suggest me how to execute set of instructions like above in powershell elevated mode?</p>
  
  <p>thanks in advance</p>