Skip to content

Instantly share code, notes, and snippets.

@fmartins-andre
Created June 11, 2021 15:02
Show Gist options
  • Save fmartins-andre/0e76d099e95acf7e9911409dad548f67 to your computer and use it in GitHub Desktop.
Save fmartins-andre/0e76d099e95acf7e9911409dad548f67 to your computer and use it in GitHub Desktop.
Bat script to run a PowerShell ps1 file that has its name equal the name this script have, bypassing policy restrictions. Useful for logon/logoff scripts.
@echo off
SET FILE=%~dp0%~n0%.ps1
::run powershell script with same name of this file
%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%FILE%' %*"
@fmartins-andre
Copy link
Author

Rename this script to the same name as your ps1 file and place them on the same folder/path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment