PowerShell

On this page, we get you up and running with Sentry's PowerShell SDK. The PowerShell Sentry SDK is tested to work with:

  • PowerShell 7.2+ on Windows, macOS, and Linux
  • Windows PowerShell 5.1

The PowerShell SDK is based on the Sentry .NET SDK. You can refer to the .NET SDK docs for the documentation of advanced features you don't find here.

Sentry captures data by using an SDK within your application’s runtime.

Install our PowerShell SDK using PowerShellGet:

Copied
Install-Module -Name Sentry -Scope CurrentUser -Repository PSGallery -Force

Configuration should happen as early as possible in your application's lifecycle.

Once this is done, Sentry's PowerShell SDK can be used to capture errors.

Copied
# You may need to import the module if you've just installed it.
Import-Module Sentry

# Start the Sentry SDK with the default options.
Start-Sentry 'https://examplePublicKey@o0.ingest.sentry.io/0'

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

Copied
try
{
    throw 'Test error'
}
catch
{
    $_ | Out-Sentry
}

To view and resolve the recorded error, log into sentry.io and open your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").