I didn't get Simon's answer to work, potentially because of other things in my path not being parsed properly by the windows git environment and/or using bonobo git server.
My objective was writing a pre-receive hook for a repository hosted in bonobo.
I ended up with the following shebang:
#!/c/Windows/System32/WindowsPowerShell/v1.0/powershell
Otherwise works identically:
- Create pre-receive file with only shebang
- Create pre-receive.ps1 in hooks directory. Powershell loads this instead.
In my case, for some cleanliness, i also used
mklink <path-to-repo>\hooks\pre-receive.ps1 c:\scripts\hooks\someLibraryScript.ps1
This allows me to keep my scripts in a central repository, of course.
EDIT: It's worth noting i did not manage to get Powershell to accept the stdin stream for the pre-receive hook. As a result, i'm still using a shell script to bootstrap powershell and pipe, rather than redirect, stdin to powershell.
In this case, i used the following shell script for my pre-receive hook:
#!/bin/sh
IFS=
echo `cat -` | powershell.exe -NoProfile -ExecutionPolicy Bypass -File "c:\scripts\hooks\pre-receive.ps1"
Powershell seems satisfied with that.