dsccommunity / SharePointDsc

The SharePointDsc PowerShell module provides DSC resources that can be used to deploy and manage a SharePoint farm
MIT License
245 stars 107 forks source link

[SPSearchIndexPartition] Regression introduced with with the fix for issue #1376 #1404

Closed ykuijs closed 2 years ago

ykuijs commented 2 years ago

Problem description

The fix for issue #1376 unfortunately introduced a regression issue: https://github.com/dsccommunity/SharePointDsc/blob/df57d18ba35b26017788ab569cece24af4aa57d4/SharePointDsc/DSCResources/MSFT_SPSearchIndexPartition/MSFT_SPSearchIndexPartition.psm1#L34-L41

The added Select-Object -First 1 only selected one Index Component. This meant that the Get method only returned one index partition (line 40), instead of only returning a single Root Directory.

Verbose logs

2022-04-22T11:48:41.4910790Z VERBOSE: [SEARCH1]:                            [[SPSearchIndexPartition]IndexPartition1] Current Values: 
2022-04-22T11:48:41.4923044Z Index=1; RootDirectory=L:\SPIndex\1; Servers=SEARCH3; ServiceAppName=Search SA
2022-04-22T11:48:41.4936309Z VERBOSE: [SEARCH1]:                            [[SPSearchIndexPartition]IndexPartition1] Target Values: Index=1;
2022-04-22T11:48:41.4949400Z  RootDirectory=L:\SPIndex\1; Servers=(SEARCH2,SEARCH3); ServiceAppName=Search SA; Verbose=True

DSC configuration

Any configuration with two servers running an index component

Suggested solution

        $searchComponent = Get-SPEnterpriseSearchComponent -SearchTopology $currentTopology -Verbose:$false | `
                Where-Object -FilterScript {
                ($_.GetType().Name -eq "IndexComponent") `
                    -and ($_.IndexPartitionOrdinal -eq $params.Index)
            }

        $IndexComponents = $searchComponent.ServerName
        $rootDirectory = ($searchComponent | Select-Object -First 1).RootDirectory

SharePoint version and build

Any

Operating system the target node is running

Any

PowerShell version and build the target node is running

Any

SharePointDsc version

v5.1