Is the following statement in a batch file unsafe?

powershell -executionpolicy bypass -File .\test.ps1

test.ps1 is located in the same folder as the batch file.

Is it possible to add something in the default powershell profile script (C:\Users\Username\Documents\WindowsPowerShell) so that another test.ps1 is loaded (e.g. a test.ps1 in a %temp% folder, instead of test.ps1 in the same folder as the batch file)

1 Answer 1


.\test.ps1 is a relative reference to a file in the current subdirectory.

There is no way that I am aware of to change how the OS will treat that path reference via a PS profile.

Note that if your batch file is located in the system path, and it is invoked from a directory other than the one where it is located, the .\test.ps1 reference will fail.

In that case, you need to use a full path to reference the file EG -File c:\scripts\test.ps1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .