Get-sqmMasterDbCustomObjects
Database HealthsqmSQLTool v1.9.110+ · Get🔓 VIEW ANY DEFINITION in master
USE statement, ad-hoc troubleshooting left behind. Unlike a user database, master has no natural owner for "this should not be here", so anything not shipped by Microsoft and not part of the standard maintenance tooling is a cleanup candidate. Reads sys.objects in master for tables, views, procedures and functions (U/V/P/PC/FN/IF/TF/FS/FT), excluding genuine Microsoft objects (is_ms_shipped = 1) and anything matched by the MasterDbObjectWhitelist module configuration (wildcards allowed, see Get-sqmConfig -Key 'MasterDbObjectWhitelist'). The default whitelist covers the standard maintenance-script family: sp_Blitz*, sp_WhoIsActive, Ola Hallengren's CommandExecute / CommandLog / DatabaseBackup / DatabaseIntegrityCheck / IndexOptimize, and sp_BackRestRemain. Output is one row per found object plus one OK row per instance with nothing found, along with TXT/CSV/HTML report files. This function only reports - use Remove-sqmMasterDbCustomObjects to drop what it finds.Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string[] | Optional | $env:COMPUTERNAME | One or more instances. Pipeline-capable. |
| -SqlCredential | PSCredential | Optional | , | SQL or Windows credential. Without it: Windows authentication. |
| -ExcludeObject | string[] | Optional | @() | Additional object names to exclude for this call only (wildcards allowed), on top of the configured whitelist. For a one-off tool you know is legitimate, without changing the persisted configuration. |
| -OutputPath | string | Optional | Get-sqmDefaultOutputPath\MasterDbCustomObjects | Output directory for the HTML/TXT/CSV report. |
| -ContinueOnError | switch | Switch | $false | Continue with the next instance on error. |
| -EnableException | switch | Switch | $false | Throw exceptions immediately instead of returning as errors. |
| -NoOpen | switch | Switch | $false | Do not automatically open the generated report. |
Execution Flow
Examples
Check the local instance
Get-sqmMasterDbCustomObjects
Several instances, with a one-off exception
Get-sqmMasterDbCustomObjects -SqlInstance 'SQL01','SQL02' -ExcludeObject 'usp_MyAdminTool'
Only the actual findings
Get-sqmMasterDbCustomObjects -SqlInstance 'SQL01' | Where-Object Status -eq 'Custom'
Feed the findings straight into the removal function (dry run first)
Get-sqmMasterDbCustomObjects -SqlInstance 'SQL01' | Where-Object Status -eq 'Custom' | Remove-sqmMasterDbCustomObjects -WhatIf
Add a legitimate tool to the whitelist permanently
Set-sqmConfig -MasterDbObjectWhitelist ((Get-sqmConfig -Key 'MasterDbObjectWhitelist') + 'usp_MyAdminTool')