Last active
August 24, 2018 16:53
-
-
Save aytch/d11acaa144f7e9cf78044a92fa366e13 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 { | |
| # If you launched Powershell normally, this will relaunch Powershell as an Admin | |
| $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