Installing dbachecks

dbachecks is a new open source module that allows the SQL Server community to crowdsource our checklists and easily test our environments 🤗 You can read more about it in our article introducing dbachecks – a new module from the dbatools team!

Requirements

The requirements for this module are a bit different than dbatools. dbatools supports PowerShell v3 but dbachecks supports PowerShell v4 and v5x. This allows us to take advantage of the faster, cooler syntax changes that became available in PowerShell v4. In addition, we have dependencies such as Pester that require a higher version.

This module does not support PowerShell v6 (Core).  

 

PowerShell

While we only require v4, we recommend using PowerShell v5.1 which runs on a variety of Windows Platforms including Windows 7 SP1. PowerShell v5.1 is faster and more secure since it has superior logging capabilities. Note that you only need a higher version of PowerShell on the workstation or server where you’ll be performing your checks.

PowerShell is installed as part of the “Windows Management Framework” or WMF.

Install and Configure WMF 5.1

 

Access to PowerShell Gallery

Online

Access to the PowerShell Gallery is required. Installing dbachecks will automatically install the required modules: dbatools, Pester and PSFramework.

For a step-by-step tutorial, check out walk-thru: installing modules from the powershell gallery.

Offline

If you are in a locked down environment, consider using an online workstation to save the required modules then copy them to one of the PowerShell paths ($env:PSModulePath) of your final destination.

This will also save the required modules. Note that it will say “installing dependent package” but it’s not installing, just saving.

For more information on installing modules offline, see the article, offline installs of dbatools.

 

Additional Modules

Required modules are automatically installed when you execute Install-Module dbachecks. Note that, like dbatools, dbachecks does not require SMO or SQL Server Management Studio to be installed.

dbatools

A majority of our checks use dbatools either for accessing local or remote Windows computers and SQL Servers.

Pester

dbachecks is basically one big Pester wrapper. Invoke-DbcCheck wraps Invoke-Pester and provides additional functionality for the SQL community, such as being able to specify -SqlServer and -ComputerName. You may notice, Pester calls them tests, but we refer to our tests as checks.

PSFramework

PSFramework, written by Friedrich Weinmann, provides easy Enterprise logging, messaging and configuration for PowerShell modules. We rely heavily on PSFramework both in dbatools (though have our custom version) and dbachecks.

 

SQL Server Agent

So you want to schedule checks using SQL Agent? Great idea! Remember that this module requires PowerShell version 4.0, which doesn’t always mesh with SQL Server’s PowerShell Job Step. To run dbachecks, we recommend you use CmdExec. You can read more at dbatools.io/agent.

If you do choose to use the PowerShell step, don’t forget to Set-Location somewhere outside of SQLSERVER:, otherwise, you’ll get errors similar to this

image

 

Troubleshooting

If you encounter any issues not described below, you can add an issue or join us in the #dbachecks channel on the SQL Server Community Slack.

 

Trouble updating Pester

Pester is built into Windows 10 and, in order to update it, needs to be “installed” once in a different way. If you encounter the error:

The required module ‘Pester’ is not loaded. Load the module or remove the module from ‘RequiredModules’

You will need to execute:

 

Random Pester error

I’m the only one that appears to have experienced this so far, but if you encounter the error Unable to find type [Pester.OutputTypes], simply Import-Module Pester and it’ll work.

 

Trouble importing

If you run a command from dbachecks and receive the following error:

The command was found in the module ‘dbachecks’, but the command could not be loaded. For more information, run ‘Import-Module dbachecks’

You likely need to update one of the required modules. In order to ensure dbachecks works as expected, we have a minimum version requirement for dbatools, Pester and PSFramework. To update, you can run

If this does not solve your issue, run Import-Module dbachecks manually.

Also, if dbachecks is loading properly and you just wanna update, you can use our built-in command Update-DbcRequiredModules or its easier to remember alias, Update-Dbachecks.

 

Read more

For more information about dbachecks, visit these links by dbachecks contributors!

- Chrissy

9 thoughts on “Installing dbachecks

  1. RP_SQL Reply

    Hello

    Is it possible to send power BI report as e-mail. I tried but no luck.

  2. Pingback: Checking Availability Groups with dbachecks | SQL DBA with A Beard

  3. sonny Reply

    Hello

    I ran offline command “Save-Module dbachecks -Path C:\temp” and get 4 folders (dbachecks, dbatools, Pester and PSframwork).
    What would be next installation steps? Have not found steps in above section “Offline – Access to PowerShell Gallery”.
    Can you share steps pls?

    Thanks in advance..

    • Chrissy LeMaire Post authorReply

      Hey Mikando, Thanks for the comment, I’ve updated the article. You’d want to copy the modules to one of the PowerShell paths ($env:PSModulePath). For more information, see dbatools.io/offline

  4. Mikando Reply

    Hello

    I ran offline command “Save-Module dbachecks -Path C:\temp” and get 4 folders (dbachecks, dbatools, Pester and PSframwork).
    What would be next installation steps? Have not found steps in above section “Offline – Access to PowerShell Gallery”.
    Can you share steps pls?


    I’m in the same case

    • Chrissy LeMaire Post authorReply

      Hey Mikando, Thanks for the comment, I’ve updated the article. You’d want to copy the modules to one of the PowerShell paths ($env:PSModulePath). For more information, see dbatools.io/offline

  5. Pingback: dbachecks implementation (part 2) – Database Misadventures

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.