Monday, August 30, 2010

PowerShell PS1 File Not Recognised as the Name of ....

Annoying wee behaviour - if calling a PowerShell file from a batch file, it seems that even if the BAT and PS1 files are in the same folder, and the BAT file has changed the current path to be that folder, it is still necessary to include the whole path to the PS1 file in the -command call.

The statements
cd [the folder path]
powershell -command "&{.\test.ps1}"
didn't work, whereas the following does work:
cd [the folder path]
powershell - command "&{[the folder path]\test.ps1}"

No comments: