Skip to content

Instantly share code, notes, and snippets.

@sheepla
Created June 18, 2022 03:50
Show Gist options
  • Select an option

  • Save sheepla/37f39e8411ba73d3acd737c5290f41b4 to your computer and use it in GitHub Desktop.

Select an option

Save sheepla/37f39e8411ba73d3acd737c5290f41b4 to your computer and use it in GitHub Desktop.
<#
.DESCRIPTION
If current user has administrator privilege, returns true else returs false.
.EXAMPLE
Test-DoIHaveAdministratorPrivilege.ps1
True
#>
$me = [System.Security.Principal.WindowsIdentity]::GetCurrent() -as [System.Security.Principal.WindowsPrincipal]
$admin = [System.Security.Principal.WindowsBuiltInRole]::Administrator
$me.IsInrole($admin) | Write-Output
@sheepla
Copy link
Author

sheepla commented Jul 9, 2022

Description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment