PowerShell is supported using the Raygun4Net provider. Most features and options documented under Raygun4Net can also be used in PowerShell.

The best way to install Raygun4Net is to use the NuGet package manager.

Visit for instructions on installation using the package manager console.

To report exceptions in a PowerShell script you will need to add the Mindscape.Raygun4Net4.dll using the Add-Type cmdlet. You then use the New-Object cmdlet to create a RaygunClient with your API key.

Add-Type -Path '[PATH-TO-DLL]\Mindscape.Raygun4Net4.dll'
$raygun = New-Object -TypeName Mindscape.Raygun4Net.RaygunClient -arg "[paste_your_api_key_here]"

ErrorAction needs to be set to stop to ensure the script execution terminates immediately and is then allowed to be handled by a Try-Catch-Finally block.

$ErrorActionPreference = "Stop"

# Or for a given cmdlet
Get-Content 'c:\notfound.txt' -ErrorAction Stop

To catch an exception and report it to Raygun you need to use a Try-Catch-Finally block. The RaygunClient instance can then be used to send the error to Raygun.

  Get-Content 'c:\notfound.txt'
Catch [Exception]

Deploy Raygun into your production environment for best results, or raise a test exception. Once we detect your first error event, the Raygun app will automatically update.

An overload of Send and SendInBackground allows you to include a list of tags with each manually sent exception:

$tags = New-Object Collections.Generic.List[String]
$raygun.Send($_.Exception, $tags)

You can include key-value custom data using an overload of the Send or SendInBackground method. Values can be primitive types or rich object structures. All properties of objects and their children will be sent to Raygun. Cyclic object references will be detected and handled as appropriate, and any property getter that produces an exception will cause that property value to be displayed as the exception message.

$customData = @{"key1"="value1"; "key2"="value2"; };
$raygun.Send($_.Exception, $null, $customData)

The second parameter is the list of tags (mentioned above) which can be null if you don't have tags for the current exception.

To set a version for reported errors you can do so by setting the ApplicationVersion property of the RaygunClient.

$raygun.ApplicationVersion = ""

The provider is open source and available at the Raygun4Net repository.