Running Powershell Script an Elevated User

・1 min read

When running a powershell script, I often find I need to run the script in an elevated prompt. The nature of my job is that often these scripts will be run by people that don’t really know what Powershell is.

I have found it quite useful to first create a bash script that the user executes, which in turn calls the actual Powershell script as an elevated user.

To keep this handy, I’m posting it here for future me.

Powershell.exe -Command "& {Start-Process Powershell.exe -ArgumentList '-ExecutionPolicy Bypass -File %~dp0actualpowershellscript.ps1' -Verb RunAs}"

I then save the bash script as something obvious such as run-me-first.bat.

Simple, but it seems to work well!