Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8477933

Browse files
Introduced -ExcludeQuery to skip specific queries
1 parent 4541bae commit 8477933

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

‎functions/Invoke-DbaDiagnosticQuery.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ function Invoke-DbaDiagnosticQuery {
139139

140140
[object[]]$ExcludeDatabase,
141141

142+
[object[]]$ExcludeQuery,
143+
142144
[Alias('Credential')]
143145
[PSCredential]$SqlCredential,
144146
[System.IO.FileInfo]$Path,
@@ -263,7 +265,10 @@ function Invoke-DbaDiagnosticQuery {
263265
}
264266
#since some database level queries can take longer (such as fragmentation) calculate progress with database specific queries * count of databases to run against into context
265267
$CountOfDatabases = ($databases).Count
266-
268+
269+
if ($ExcludeQuery) {
270+
$QueryName = Compare-Object -ReferenceObject $QueryName -DifferenceObject $ExcludeQuery | Where-Object SideIndicator -eq "<=" | Select-Object -ExpandProperty InputObject
271+
}
267272

268273
if ($QueryName.Count -ne 0) {
269274
#if running all queries, then calculate total to run by instance queries count + (db specific count * databases to run each against)

‎tests/Invoke-DbaDiagnosticQuery.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
5151
@($results | Where-Object {$_.Database -eq $Database}).Count | Should -BeGreaterThan 1
5252
@($results | Where-Object {$_.Database -eq $Database2}).Count | Should -Be 0
5353
}
54+
It "Correctly excludes queries" {
55+
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'Version Info', 'Core Counts', 'Server Properties' -ExcludeQuery 'Core Counts'
56+
@($results).Count | Should be 2
57+
}
5458

5559
$columnnames = 'Item', 'RowError', 'RowState', 'Table', 'ItemArray', 'HasErrors'
5660
$TestCases = @()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /