You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
568 B

  1. param([switch]$Elevated)
  2. function Check-Admin {
  3. $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
  4. $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
  5. }
  6. if ((Check-Admin) -eq $false) {
  7. if ($elevated)
  8. {
  9. # could not elevate, quit
  10. }
  11. else {
  12. Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
  13. }
  14. exit
  15. }
  16. ac -Encoding UTF8 C:\Windows\system32\drivers\etc\hosts "127.0.0.1 identity.service"