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.
Access to PowerShell Gallery
Online
Access to the PowerShell Gallery is required. Installing dbachecks will automatically install the required modules: dbatools, Pester and PSFramework.
Install-Module -Name dbachecks
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.
Save-Module -Name dbachecks -Path C:\temp
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
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:
Install-Module Pester -SkipPublisherCheck -Force Import-Module Pester -Force
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
Update-Module -Name dbachecks, dbatools, PSFramework, Pester
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!
- Announcing dbachecks – Configurable PowerShell Validation For Your SQL Instances by Rob Sewell
- introducing dbachecks - a new module from the dbatools team! by Chrissy LeMaire
- dbachecks commands by Chrissy LeMaire
- dbachecks – Using Power BI dashboards to analyse results by Cláudio Silva
- My wrapper for dbachecks by Tony Wilhelm
- Checking backups with dbachecks by Jess Promfret
- dbachecks please! by Garry Bargsley
- dbachecks – Configuration Deep Dive by Rob Sewell
- Test Log Shipping with dbachecks
- Checking your backup strategy with dbachecks by Joshua Corrick
- Enterprise-level reporting with dbachecks by Jason Squires
- Adding your own checks to dbachecks by Shane O'Neill
- dbachecks - A different approach for an in-progress and incremental validation by Cláudio Silva
- Chrissy