Run escalated PowerShell script from a batch file
Views (85)
I posted a Power Shell snippet a while ago on bypassing the execution policy. More recently I needed to combine that with running a script with administrator permissions. I did a little exploring and found an article by Adam Dimech which contained this code which can be run from a batch file:
Change the highlighted section to your saved ps1 file and you can run that script escalated with administrator permissions.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""{path and filename of ps1 file}""' -Verb RunAs}"
Click to show/hide the PowerShell Snippets Series Index
| PowerShell Snippets |
|---|
| Write-Output |
| Start-Sleep |
| PowerShell to run script bypassing execution policy |
| Unlock BitLocker protected drive with PowerShell |
| Run escalated PowerShell script from a batch file |
(Visited 9 times, 1 visits today)
This was originally posted here.

Like
Report
*This post is locked for comments