Geek Noise
Rants, rambles, news and notes by Peter Provost
26

Shifting Powershell Arrays

Monday, 26 February 2007 04:25 by Peter Provost

In one of my recent posts, I showed a newer version of my 'sudo for Powershell' that was all writted in Powershell and left an open question about how to collect the variable arguments at the end.

Wes Haggard again comes through with the answer and points me to a post on the Powershell Blog called PowerShell Tip: How to “shift” arrays…

Using that tip, Wes gave me back a much tighter version of the elevation function:

function elevate
{
$file, [string]$arguments = $args;
$psi = new-object System.Diagnostics.ProcessStartInfo $file;
$psi.Arguments = $arguments;
$psi.Verb = "runas";
[System.Diagnostics.Process]::Start($psi);
}

Killer! Thanks again Wes!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  
Categories:   Technology
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed
Comments are closed