Run escalated PowerShell script from a batch file

PowerShellI 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}"

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Looking for support or consultancy with Microsoft Dynamics GP?

I no longer work with Microsoft Dynamics GP, but the last company I worked for was ISC Software in the UK; if you’re looking for support or consultancy services with Microsoft Dynamics GP you can contact them here.

1 thought on “Run escalated PowerShell script from a batch file

Leave a Reply

Your email address will not be published. Required fields are marked *