Create a ps.bat file with one line:
Save this file in an appropriate location. I saved mine to:
Add a custom action to SourceTree.
You do this by going to
Tools -> Options -> Custom Actions
Click the 'Add' button and you will get another Window.
On the 'Menu caption' type an identifier for PowerShell and on 'Script to run' navigate to the script you made in step 1 then click 'OK' and exit from the 'Options' Window.