Created
September 13, 2018 02:01
-
-
Save aytch/308fc0452184e3e0c1c9ceec19cc1d7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Set-ElevatedStatus { | |
| $WindowsPrincipal = new-object System.Security.Principal.WindowsPrincipal(` | |
| [System.Security.Principal.WindowsIdentity]::GetCurrent() | |
| ) | |
| $IsAdmin = $WindowsPrincipal.IsInRole(` | |
| [System.Security.Principal.WindowsBuiltInRole]::Administrator) | |
| if ($IsAdmin -eq $True) { | |
| # No action required | |
| } | |
| else { | |
| Start-Process powershell -Verb runas | |
| exit | |
| } | |
| } | |
| Set-ElevatedStatus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment