Skip to content

Commit

Permalink
added checkAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
robledosm committed Aug 18, 2017
1 parent 8ff9b28 commit 0e491cb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions update-mvpsHosts.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
#Requires -RunAsAdministrator
Add-Type -AssemblyName System.IO.Compression.FileSystem
Add-Type -AssemblyName System.IO.Compression.FileSystem
param([switch]$Elevated)
function checkAdmin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((checkAdmin) -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
}
function Unzip {
param([string]$zipfile, [string]$outpath)

Expand Down

0 comments on commit 0e491cb

Please sign in to comment.