PoshCode Archive  Artifact [b3820c301b]

Artifact b3820c301be83bace263a4f29c9699f73ab68f04e8a30d013607bebbb8c88433:

  • File elevate-process-sudo.ps1 — part of check-in [ea9a53f357] at 2018-06-10 14:22:39 on branch trunk — As a former UNIX guy, I love the non-admin stuff in Vista, but got annoyed keeping two shells open (one admin and one non-admin). I wanted sudo! PowerShell made that easy. Enjoy! (user: Peter Provost size: 775)

# encoding: ascii
# api: powershell
# title: elevate-process (sudo)
# description: As a former UNIX guy, I love the non-admin stuff in Vista, but got annoyed keeping two shells open (one admin and one non-admin). I wanted sudo! PowerShell made that easy. Enjoy!
# version: 0.1
# type: function
# author: Peter Provost
# license: CC0
# function: elevate-process
# x-poshcode-id: 695
# x-archived: 2017-03-12T06:20:40
# x-published: 2009-12-02T10:12:00
#
#
function elevate-process
{
	$file, [string]$arguments = $args;
	$psi = new-object System.Diagnostics.ProcessStartInfo $file;
	$psi.Arguments = $arguments;
	$psi.Verb = "runas";
	$psi.WorkingDirectory = get-location;
	[System.Diagnostics.Process]::Start($psi);
}

set-alias sudo elevate-process;