Last active
August 29, 2015 14:26
-
-
Save svandragt/cb7c2003cdf8f0a9d5c7 to your computer and use it in GitHub Desktop.
FogBugz: BugzScout Automatic Crash Reporting using powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ErrorActionPreference = "Stop" | |
| #region functions - put this in an include and add it to every script | |
| function DoTrap() { | |
| $script = $_.InvocationInfo.ScriptName | |
| $line = $_.InvocationInfo.ScriptLineNumber | |
| $_errorDetails = $Error[0] | fl * -force | Out-string | |
| if (Submit-BugzScoutReport -Description "TEST: $script:$line" -Extra $_errorDetails) { | |
| Write-Host "Error reported." | |
| } else { | |
| Write-Warning "Error could not be reported." | |
| } | |
| } | |
| #endregion | |
| # Set the trap and force the Error | |
| trap { DoTrap } | |
| 1/0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A minimal module | |
| function Submit-BugzScoutReport { | |
| param( | |
| $Description, | |
| $Extra, | |
| $ScoutProject = 'Your Project' | |
| ) | |
| $r = @{} | |
| $r.ScoutUserName = 'BugzScout' | |
| $r.ScoutProject = $ScoutProject | |
| $r.ScoutArea = 'Misc' | |
| $r.Description = $Description | |
| $r.Extra = $Extra | |
| return Invoke-RestMethod http://your.fogbugz.url/scoutSubmit.asp -Body $r | |
| } | |
| Export-ModuleMember -Function "*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment