Skip to content

Instantly share code, notes, and snippets.

@nyanhp
Created April 6, 2022 14:38
Show Gist options
  • Save nyanhp/145f715e41ea84b8247b66ea13aaaa26 to your computer and use it in GitHub Desktop.
Save nyanhp/145f715e41ea84b8247b66ea13aaaa26 to your computer and use it in GitHub Desktop.
if (-not (Test-IsAdministrator))
{
Write-Host -ForegroundColor Magenta 'Not an Admin :('
Start-Process -Verb runAs -FilePath (Get-Process -Id $pid).Path -ArgumentList "-File $PSScriptRoot" -WindowStyle Hidden
}
Write-Host -ForegroundColor Magenta 'Admin :)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment