Skip to content

Instantly share code, notes, and snippets.

@RobsonAutomator
Last active November 10, 2017 16:13
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 RobsonAutomator/0d5fa2030da0572953595d966dc735b7 to your computer and use it in GitHub Desktop.
Save RobsonAutomator/0d5fa2030da0572953595d966dc735b7 to your computer and use it in GitHub Desktop.
Check if current user has administrator rights
if( -not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Warning -Message "Please run this script with Administrator rights"
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment