adminPriv.ps1
|
<#
.SYNOPSIS Admin Priveledges .DESCRIPTION Checks if the scipt is running as adming and if not, prompt for admin credentials and runs the script again. #> if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { # If not running as administrator, re-launch the script with administrative privileges Start-Process -FilePath "powershell" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs exit } Read-Host -p "Press 'ENTER' to continue" |