Skip to main content

Depending on whether or not you need Administrator permissions for your PowerShell script (and you really shouldn't be requesting them if you don't) the final batch file should look like one of the two below.
Remember to put the batch file in the same folder as the PowerShell script you want to use it for, and give it the same name. Then, no matter what system you take those files to, you'll be able to run your PowerShell script without having to muck around with any of the security settings on the system. You could certainly do those changes manually every time, but this saves you that trouble and you won't have to worry about reverting the changes later.

::
:: Without Admin access
::
:: NOTE: replace "& '%~dpn0.ps1'" with "& "& 'C:\path\to\ps_script.ps1'" if batch file
:: and powershell script have different file names.
@echo off
powershell.exe -noprofile -executionpolicy bypass -command "& '%~dpn0.ps1'"
pause

::
:: With Admin access
::
:: NOTE: replace "& '%~dpn0.ps1'" with "& "& 'C:\path\to\ps_script.ps1'" if batch file
:: and powershell script have different file names.
@echo off
powershell.exe -noprofile -command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
pause