Skip to content

Instantly share code, notes, and snippets.

@wheelerlaw
Last active September 29, 2023 16:22
Show Gist options
  • Save wheelerlaw/a426fb609715a2c7cc156c6aabb6076f to your computer and use it in GitHub Desktop.
Save wheelerlaw/a426fb609715a2c7cc156c6aabb6076f to your computer and use it in GitHub Desktop.
Running elevated commands from a non-elevated git-bash with the ability to pipe/redirect the output of the elevated command.
#!/usr/bin/env bash
elevate() {
powershell -Command "Start-Process cmd -ArgumentList \"/c\",\"$1 2>&1 | clip\" -Verb RunAs"
powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment