Skip to content

Instantly share code, notes, and snippets.

@lorengordon
Created January 29, 2018 18:34
Show Gist options
  • Save lorengordon/7100b00e4d02518cdbacbcb0bf4f9706 to your computer and use it in GitHub Desktop.
Save lorengordon/7100b00e4d02518cdbacbcb0bf4f9706 to your computer and use it in GitHub Desktop.
Powershell profile with admin check
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator"))
{
Write-Warning "Skipping functions that require elevated permissions..."
}
else
{
# Do admin stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment