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 bf07fca

Browse files
Some looping logic changed to prevent duplicates in the output.
1 parent 37a0ccc commit bf07fca

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

‎functions/Invoke-DbaDiagnosticQuery.ps1‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ function Invoke-DbaDiagnosticQuery {
344344
DatabaseSpecific = $scriptpart.DBSpecific
345345
Database = $null
346346
Notes = $null
347-
Result = Select-DefaultView -InputObject $result -Property *
347+
#Result = Select-DefaultView -InputObject $result -Property *
348+
#Not using Select-DefaultView because excluding the fields below doesn't seem to work
349+
Result = $result | Select-Object * -ExcludeProperty 'Item', 'RowError', 'RowState', 'Table', 'ItemArray', 'HasErrors'
348350
}
349351

350352
}
@@ -399,7 +401,7 @@ function Invoke-DbaDiagnosticQuery {
399401
Name = $scriptpart.QueryName
400402
Description = $scriptpart.Description
401403
DatabaseSpecific = $scriptpart.DBSpecific
402-
Database = $null
404+
Database = $currentdb
403405
Notes = "Empty Result for this Query"
404406
Result = $null
405407
}
@@ -410,17 +412,21 @@ function Invoke-DbaDiagnosticQuery {
410412
Write-Message -Level Verbose -Message ('Some error has occured on Server: {0} - Script: {1} - Database: {2}, result will not be saved' -f $instance, $scriptpart.QueryName, $currentDb) -Target $currentdb -ErrorRecord $_
411413
}
412414

413-
[pscustomobject]@{
414-
ComputerName = $server.NetName
415-
InstanceName = $server.ServiceName
416-
SqlInstance = $server.DomainInstanceName
417-
Number = $scriptpart.QueryNr
418-
Name = $scriptpart.QueryName
419-
Description = $scriptpart.Description
420-
DatabaseSpecific = $scriptpart.DBSpecific
421-
Database = $currentDb
422-
Notes = $null
423-
Result = Select-DefaultView -InputObject $result -Property *
415+
if ($result){
416+
[pscustomobject]@{
417+
ComputerName = $server.NetName
418+
InstanceName = $server.ServiceName
419+
SqlInstance = $server.DomainInstanceName
420+
Number = $scriptpart.QueryNr
421+
Name = $scriptpart.QueryName
422+
Description = $scriptpart.Description
423+
DatabaseSpecific = $scriptpart.DBSpecific
424+
Database = $currentDb
425+
Notes = $null
426+
#Result = Select-DefaultView -InputObject $result -Property *
427+
#Not using Select-DefaultView because excluding the fields below doesn't seem to work
428+
Result = $result | Select-Object * -ExcludeProperty 'Item', 'RowError', 'RowState', 'Table', 'ItemArray', 'HasErrors'
429+
}
424430
}
425431
}
426432
else {

0 commit comments

Comments
(0)

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