From f707a6358c31b17c8d166d5b818c44b75868ea07 Mon Sep 17 00:00:00 2001 From: Patrick Flynn Date: Sun, 3 Feb 2019 23:36:30 +1100 Subject: [PATCH] Get-DbaDbccMemoryStatus - remove dependency on system.data objects and use standard constructs (#5031) * Remove dependancy on system.Data objects * Fix case of variable * Modify to use the .query custom method --- functions/Get-DbaDbccMemoryStatus.ps1 | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/functions/Get-DbaDbccMemoryStatus.ps1 b/functions/Get-DbaDbccMemoryStatus.ps1 index f0468f1638..9ecf69709e 100644 --- a/functions/Get-DbaDbccMemoryStatus.ps1 +++ b/functions/Get-DbaDbccMemoryStatus.ps1 @@ -64,19 +64,13 @@ function Get-DbaDbccMemoryStatus { Write-Message -Level Verbose -Message "Collecting $query data from server: $instance" try { - $sqlconnection = New-Object System.Data.SqlClient.SqlConnection - $sqlconnection.ConnectionString = $server.ConnectionContext.ConnectionString - $sqlconnection.Open() - - $datatable = New-Object system.Data.DataSet - $dataadapter = New-Object system.Data.SqlClient.SqlDataAdapter($query, $sqlconnection) - $dataadapter.fill($datatable) | Out-Null + $datatable = $server.query($query, 'master', $true) $recordset = 0 $rowId = 0 $recordsetId = 0 - foreach ($dataset in $datatable.Tables) { + foreach ($dataset in $datatable) { $dataSection = $dataset.Columns[0].ColumnName $dataType = $dataset.Columns[1].ColumnName $recordset = $recordset + 1