Our database scripts reside in our SVN repo and when we do an svn update we want to have a friendly reminder if they've been modified by another developer (so that we can sync up our local database). Client hook scripts seemed like a perfect choice for this, as did a PowerShell script. I ran into many quirks while trying to make this happen, one of which was that TSVN captures the output of a hook script in order to catch errors. This means that you cant really use hook scripts OOB for displaying a message. If your interested in having a setting in TSVN to change this behavior, please post a comment here.  Although in PowerShell we can issue a command to start up a new PowerShell instance to run our script, freeing us from the shackles of TSVN:

powershell.exe -command "& {start-process powershell.exe (([system.environment]::GetCommandLineArgs()|ForEach-Object -process { '\"{0}\"' -f $_ })[3..([system.environment]::GetCommandLineArgs().Length-1)])}" "-file" "C:\MyScript.ps1"

This command deals with some other quirks that I ran into. One is that the $args variable contains improperly parsed command line arguments when used in a -command. It doesn't respect quoted qualifiers and splits on spaces even when a parameter is quote qualified. Also they need to be requalified before they are passed to the script or you run into the same issue. The command also drops the first few parameters as these are not needed and cause problems.

So all you have to do is create a hook script under TSVN settings and paste in the above command (With the path to your script) and your good to go. I suggest checking the "Hide the script..." checkbox as this call will cause an initial console window to popup and disappear if you don't.

image