Skip to content

Instantly share code, notes, and snippets.

@marcinantkiewicz
Created October 19, 2022 03:21
Show Gist options
  • Save marcinantkiewicz/9013d44f5e116d3d549a4a53a6031058 to your computer and use it in GitHub Desktop.
Save marcinantkiewicz/9013d44f5e116d3d549a4a53a6031058 to your computer and use it in GitHub Desktop.
if (-Not([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){
Write-Host "Not admin, elvevating"
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit
}
else {
Write-Host "I hate PS so, so much"
Start-Sleep -Second 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment