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

Add the below to the top of your script

[pastacode lang=”markdown” manual=”if%20(!(%5BSecurity.Principal.WindowsPrincipal%5D%5BSecurity.Principal.WindowsIdentity%5D%3A%3AGetCurrent()).IsInRole(%5BSecurity.Principal.WindowsBuiltInRole%5D%20%22Administrator%22))%20%7B%20Start-Process%20powershell.exe%20%22-NoProfile%20-ExecutionPolicy%20Bypass%20-File%20%60%22%24PSCommandPath%60%22%22%20-Verb%20RunAs%3B%20exit%20%7D%0A%0A%23%20Your%20script%20here” message=”” highlight=”” provider=”manual”/]

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...