Is Windows PowerShell supported ?

RGUser

Posted on
Jun 27 2015

Hi,

Just wanted to check if you have powershell support for Raygun.

Thanks,


Jamie Penney

Posted on
Jun 29 2015

Hi,

Raygun4Net is a standard .NET library, so you can use it from PowerShell like you would any other library using the Add-Type Cmdlet (in PS 2.0 and above). We don't have any specific documentation on it, but you should be able to Trap unhandled exceptions in your script, then create a new RaygunClient and Send() them.

Best Regards,
Jamie


MortenMA

Posted on
Nov 04 2019

RGUser. Did you ever get your Powershell script to send exceptions to Raygun? If yes, would you share some of your experiences?

Thanks in advance

Best regards Morten


Deleted User

Raygun

Posted on
Nov 07 2019

This example works for me with Raygun4Net 5.10.0

Add-Type -Path '[PATH-TO-DLL]\Mindscape.Raygun4Net4.dll'

# set ErrorAction to stop in order for the script to continue to the catch block rather than terminate. 
$ErrorActionPreference = "Stop"
$raygun = New-Object -TypeName Mindscape.Raygun4Net.RaygunClient -arg "[YOUR-API-KEY]"

Try
{
    #Something that causes an error or try, throw "message for the exception"
    Get-Content 'c:\notfound.txt'
}
Catch [Exception]
{
    $raygun.Send($_.Exception)
}

Deleted User

Raygun

Posted on
Nov 08 2019

Just another quick update that this is documented in detail now at https://raygun.com/documentation/language-guides/powershell/crash-reporting/installation/


MortenMA

Posted on
Nov 11 2019

Thanks, jnorman. Works perfectly.


Reply