19 lines
568 B
PowerShell
19 lines
568 B
PowerShell
param([switch]$Elevated)
|
|
function Check-Admin {
|
|
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
|
|
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
|
|
}
|
|
if ((Check-Admin) -eq $false) {
|
|
if ($elevated)
|
|
{
|
|
# could not elevate, quit
|
|
}
|
|
|
|
else {
|
|
|
|
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
|
|
}
|
|
exit
|
|
}
|
|
|
|
ac -Encoding UTF8 C:\Windows\system32\drivers\etc\hosts "127.0.0.1 identity.service" |