How to elevate existing powershell Windows to Local Admin ( UAC )

Add the below to the top of your script

if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }

# Your script here
GD Star Rating
loading...
GD Star Rating
loading...

Trackback from your site.