PSDPA - Database Performance Analyzer PowerShell Module

With the release of the Database Performance Analyzer 12.1 and the Management API, I have started developing a PowerShell module called PSDPA. The module is now available through the PowerShell Gallery and GitHub. I would still consider this release a "beta" release, as not everything has been implemented and not everything has been tested. If you have ideas on additional features - feel free to submit a GitHub issue. Pull requests are also welcome!

Prerequisites

  • PowerShell 5.x
  • PSFramework PowerShell Module
  • DPA 12.1 and an API Refresh Token

Installation

if (-not (Get-Module PSFramework -ListAvailable)) { Install-Module PSFramework }

Install-Module PSDPA

Configuration

Set-DpaConfig -BaseUri 'http://yourserver:8123/iwc/api' -RefreshToken 'yourrefreshtoken'

Links

PowerShell Gallery

GitHub

Practical Examples

# add an annotation to all servers after patching

Get-DpaMonitor | Add-DpaAnnotation -Title "Patching" -Description "Operating system patching"

# reboot a server, but make sure to stop/start DPA on the instance before so we don't get alerts

Stop-DpaMonitor -MonitorName "MyServer"

Restart-Computer -ComputerName "MyServer"

Start-DpaMonitor -MonitorName "MyServer"

Top Replies

  • awickham10​ :

    I get the following error when attempting to add an annotation to an Azure SQL Database instance/database. Oddly, I can add an annotation both via Swagger and by creating a full-blown PowerShell script. But the one-line Add-DpaAnnotation approach in the example above gives this:

    New-Object : Cannot find type [AzureSQLDatabaseMonitor]: verify that the assembly containing this type is loaded.

    At C:\Program Files\WindowsPowerShell\Modules\PSDPA\0.0.1\Classes\Monitor.ps1:87 char:17

    +         return (New-Object -TypeName "$type" -ArgumentList $Json)

    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException

        + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Which is unfortunate, because this would be my preferred approach.

    Thanks in advance for any help.

  • Hi gjspielman​ - I'm working on getting a testing environment to get some support setup for Azure SQL DB. That's an area we are not currently using, so I wasn't able to test it. I'll post back here soon with an update!

  • gjspielman​​ - I got my lab environment up and running and just released 0.0.2 which resolves your issue. You can get the latest version by doing an Update-Module in PowerShell.

    Any feedback is appreciated!

  • Worked perfectly on the first try! Awesome work, awickham10​!

  • I do not hold any current DPA instances at the moment, but will give this a try as soon as I get my hands on a new environment, nice work!

  • Amy1_0-1603391982289.png

        i want to register SQLServer instance to Solarwinds DPA using REST API. But i am stuck at token part as it keeps failing with error 500

    Method1:

    I tried to do this using steps mentioned in https://documentation.solarwinds.com/en/Success_Center/DPA/Content/DPA-powershell-script-examples.htm and it failed(i am using self signed cert so i included that part in script) with 500 error

    #----------------------------------------------------------
    # Adding certificate exception to prevent API errors
    #----------------------------------------------------------										
    											
    add-type @"
      using System.Net;
      using System.Security.Cryptography.X509Certificates;
      public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
          ServicePoint srvPoint, X509Certificate certificate,
          WebRequest request, int certificateProblem) {
          return true;
        }
      }
    "@
    [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

    Method2:

    I tried using management API documentation link in my options>utilities>management api documentation

    I input my token value there and i am getting same 500 error

    Method 3:

    My last method was to use PSDPA powershell module(screenshot attached). i still get same error 500.

    How can i fix this? Anyone having similar issue? 

  • Have you taken a look at the DPA logs to see if there are any more details? A 500 response code usually indicates a problem happened while processing the request.