Created
June 11, 2021 15:02
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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%' %*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rename this script to the same name as your ps1 file and place them on the same folder/path.