title: Powershell - How to use Start-Process to call file from share/pass args in single line
body: <p>To preface this, I am self teaching and brand new to scripting in general, let alone powershell.
  After a cumulative 12 hours, my Google fu has run out.</p>
  <p>I had a series of programs tailored to different models of computer we support that ran a staged series of installers from a fileshare.  The program would check to see if the tech deploying the software was running it as admin, if not, it used a <code>Start-Process</code> line to elevate and run again.</p>
  <p>It worked flawlessly, but we wanted to see if we could remove the need for the tech to enter r to run the scripts from the share.</p>
  <p>In trying to figure out how to add <code>-executionpolicy bypass</code> to the arg list for <code>Start-Process</code>, I've hit a wall.</p>
  <p>It now errors on trying to call to the fileshare to retrieve the parent script, before getting to the point where I can troubleshoot the <code>bypass</code> can of worms.</p>
  <p>Below is my rough framework, remember I'm self taught by googling and using tutorials point.</p>
  <pre><code>$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  if($principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) 
      {
  #usually I have a get-childitem | foreach-object loop here that runs the files from the folder one by one in a specific order,
  #it also checks to see if msiexec is running or not before trying to load and install files using a if-else&gt;do-while combo
      }
  else 
      {
          Start-Process -FilePath &quot;powershell&quot; -ArgumentList &quot;$('-File &quot;\\server\dir\foo&quot;.ps1')$($MyInvocation.MyCommand.Name)$('&quot;&quot;')&quot; -Verb runAs
      }#this calls to a script that is a 1:1 copy of the code in the if{} block
  </code></pre>
  <p>This returns an error from the <code>-File</code> parameter that says it can't call the file because it doesn't exist.
  What am I doing wrong?
  How do I pass <code>-executionpolicy bypass</code> as an additional arg without breaking it further?
  Is there a better way to do this?
  Is there a neater way to automate this?</p>
  <p>Please help me geniuses of StackOverflow before I start gnawing on my keyboard.</p>