Skip to content

Instantly share code, notes, and snippets.

@ctrl-freak
Created July 10, 2017 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrl-freak/12d55bb6c6db1b4f8f68ec438086b65f to your computer and use it in GitHub Desktop.
Save ctrl-freak/12d55bb6c6db1b4f8f68ec438086b65f to your computer and use it in GitHub Desktop.
Elevate PowerShell
# Ask for elevated permissions if required
# https://github.com/Scine/Powershell/blob/master/ReclaimWindows10.ps1
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
Exit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment