If you have a custom PowerShell script you wish to run you can create a tool in release Management (Inventory > Tools) for the script which deploys the .PS1, PSM files etc. and defines the command line to run it.
The problem we hit was that our script failed, but did not fail the build step as the PowerShell.EXE running the script exited without error. The script had thrown an exception which was in the output log file, but it was marked as a completed step.
The solution was to use a try/catch in the .PS1 script that as well as writing a message to Write-Error also set the exit code to something other than 0 (Zero). So you end up with something like the following in your .PS1 file
param
(
\[string\]$Param1 ,
\[string\]$Param2 )
try
{
# some logic here
} catch
{
Write-Error $\_.Exception.Message
exit 1 # to get an error flagged so it can be seen by RM
}
Once this change was made an exception in the PowerShell caused the release step to fail as required. The output from the script appeared as the Command Output.