Created
August 14, 2020 19:15
-
-
Save BanterBoy/008abed0caca15ad3d0678efcf4076f5 to your computer and use it in GitHub Desktop.
Function used in conjunction with Test-IsAdmin to start a new Microsoft Terminal as Admin
This file contains 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 New-AdminTerminal { | |
<# | |
.Synopsis | |
Starts an Elevated Microsoft Terminal. | |
.Description | |
Opens a new Microsoft Terminal Elevated as Administrator. If the user is already running an elevated | |
Microsoft Terminal, a message is displayed in the console session. | |
.Example | |
New-AdminShell | |
#> | |
if (Test-IsAdmin = $True) { | |
Write-Warning -Message "Admin Shell already running!" | |
} | |
else { | |
Start-Process "wt.exe" -ArgumentList "-p pwsh" -Verb runas -PassThru | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment