title: Powershell Getting $myIvocation of calling script
body: <p>I am trying to create an Elevate function that Elevates the script that called the function
  However While the function in it's current form works  I am trying to make it more elegant by removing the Invocation Parameter and getting the function to automatically determine the information by using scope.</p>
  
  <p>Here is what works currently</p>
  
  <pre><code>Function Elevate ($Invocation)
  {
      $myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
      $myWindowsPrincipal=New-Object System.Security.Principal.WindowsPrincipal($myWindowsID)
      $adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
      if (-not $myWindowsPrincipal.IsInRole($adminRole))
      {
          $newProcess = New-Object System.Diagnostics.ProcessStartInfo "Powershell";
          $newProcess.Arguments = $Invocation.MyCommand.Definition
          $newProcess.Verb = "runas";
          [System.Diagnostics.Process]::Start($newProcess);
          exit;
      }
  }
  </code></pre>
  
  <p>I want to do away with the $Invocation variable if possible.
  Is there a way to get this from the parent?</p>
  
  <p>Thanks in advance</p>
  
  <p>Tim</p>