Skip to content

Instantly share code, notes, and snippets.

@BanterBoy
Created August 14, 2020 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BanterBoy/008abed0caca15ad3d0678efcf4076f5 to your computer and use it in GitHub Desktop.
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
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