diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ee782e24..656d6a701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,9 @@ - Changes to xSQLServerRole - Running Get-DscConfiguration no longer throws an error saying property Members is not an array ([issue #790](https://github.com/PowerShell/xSQLServer/issues/790)). +- Changes to xSqlServerMaxDop + - Fixed error where Measure-Object cmdlet would fail claiming it could not + find the specified property ([issue #801](https://github.com/PowerShell/xSQLServer/issues/801)) ## 8.1.0.0 diff --git a/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 b/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 index 0f8013359..206d8db23 100644 --- a/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 +++ b/DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1 @@ -212,7 +212,7 @@ function Test-TargetResource switch ($Ensure) { 'Absent' - { + { if ($getMaxDop -ne 0) { New-VerboseMessage -Message "Current MaxDop is $getMaxDop should be updated to 0" @@ -260,8 +260,21 @@ function Test-TargetResource function Get-SqlDscDynamicMaxDop { $cimInstanceProc = Get-CimInstance -ClassName Win32_Processor - $numProcs = (Measure-Object -InputObject $cimInstanceProc -Property NumberOfLogicalProcessors -Sum).Sum - $numCores = (Measure-Object -InputObject $cimInstanceProc -Property NumberOfCores -Sum).Sum + + # init variables + $numProcs = 0 + $numCores = 0 + + # Loop through returned objects + foreach ($processor in $cimInstanceProc) + { + # increment number of processors + $numProcs += $processor.NumberOfLogicalProcessors + + # increment number of cores + $numCores += $processor.NumberOfCores + } + if ($numProcs -eq 1) {