Skip to content

Instantly share code, notes, and snippets.

@moddingg33k
Last active August 7, 2020 06:44
Show Gist options
  • Save moddingg33k/508d86900eabe29f9211e43528cfb500 to your computer and use it in GitHub Desktop.
Save moddingg33k/508d86900eabe29f9211e43528cfb500 to your computer and use it in GitHub Desktop.
$currentIdentity = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
$isAdministrator = $currentIdentity.IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')
if (-not $isAdministrator) {
$Arguments = ('& ''{0}''' -f $MyInvocation.MyCommand.Definition)
Start-Process PowerShell.exe -Verb RunAs -ArgumentList $Arguments
break
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment