Skip to content

Commit

Permalink
xSQLServerMaxDop: Measure-Resource value of Property is not valid (ds…
Browse files Browse the repository at this point in the history
…ccommunity#802)

- Changes to xSQLServerMaxDop
  - Fixed error where Measure-Object cmdlet would fail claiming it could not
    find the specified property (issue dsccommunity#801).
  • Loading branch information
twerthi authored and johlju committed Sep 13, 2017
1 parent dbca42c commit 5c6745b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 16 additions & 3 deletions DSCResources/MSFT_xSQLServerMaxDop/MSFT_xSQLServerMaxDop.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 5c6745b

Please sign in to comment.