Function Check-Administrator {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )
if ($currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )) {
return $true
} else {
return $false
}
}
#Check for elevated mode
if (-not (Check-Administrator)) {
Write-Warning "This script needs to be executed in elevated mode. Start the Shell as an Administrator and try again."
$Error.Clear()
Exit
}
Created
June 22, 2022 09:57
-
-
Save MiroXP/e8aafd778de66ee18974c52bc0673ae4 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment