Skip to content

Instantly share code, notes, and snippets.

@caphosra
Created December 12, 2019 06:14
Show Gist options
  • Select an option

  • Save caphosra/e0765d672a0ec8da07151abbcfa5f826 to your computer and use it in GitHub Desktop.

Select an option

Save caphosra/e0765d672a0ec8da07151abbcfa5f826 to your computer and use it in GitHub Desktop.
Implementation of sudo command on Powershell
# A function that runs some commands with administrator rights.
function SudoRun
{
# Set commands to $program.
foreach($arg in $args)
{
$program = "$program $arg"
}
# Run it by Powershell with administrator rights.
pwsh -command "Start-Process -Verb runas $program"
}
# Set the function as an new alias.
Set-Alias -Name sudo -Value SudoRun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment