Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPSearchCrawlerImpactRule: Get-TargetResource throws if Impact Rule does not exist #1444

Open
ChristophHannappel opened this issue Dec 23, 2024 · 1 comment · May be fixed by #1445
Open

Comments

@ChristophHannappel
Copy link
Contributor

ChristophHannappel commented Dec 23, 2024

Problem description

The Get-TargetRessouce Function throws an terminating error if the Crawler Impact Rule does not exist.

Verbose logs

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ResourceGet,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer ServerName with user sid S-1-5-21-SID-SID-SID-SID.
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Getting Crawler Impact Rule Setting for 'fileservice.contoso.com'
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Executing as the local run as user CONTOSO\PsDscRunAccount
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Leaving BeginProcessing Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Leaving ProcessRecord Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Leaving EndProcessing Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Leaving BeginProcessing Method of Get-SPEnterpriseSearchSiteHitRule.
Object fileservice.contoso.com not found.
    + CategoryInfo          : InvalidData: (Microsoft.Offic...archSiteHitRule:) [], CimException
    + FullyQualifiedErrorId : Microsoft.Office.Server.Search.Cmdlet.GetSearchSiteHitRule
    + PSComputerName        : localhost
 
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Leaving ProcessRecord Method of Get-SPEnterpriseSearchSiteHitRule.
VERBOSE: [ServerName]:                            [[SPSearchCrawlerImpactRule]DirectResourceAccess] Leaving EndProcessing Method of Get-SPEnterpriseSearchSiteHitRule.
The PowerShell DSC resource '[SPSearchCrawlerImpactRule]DirectResourceAccess' with SourceInfo '' threw one or more non-terminating errors while running the Get-TargetResource 
functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost
 
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 7.698 seconds

DSC configuration

Invoke-DscResource -Name SPSearchCrawlerImpactRule -ModuleName SharePointDSC -Method Get -Property @{
    PsDscRunAsCredential = $Cred
    Name = 'fileservice.contoso.com'
    RequestLimit = 32
    ServiceAppName = "SearchService_Default"
}

Suggested solution

Change

$crawlerImpactRule = Get-SPEnterpriseSearchSiteHitRule -Identity $params.Name -SearchService $params.ServiceAppName

to $crawlerImpactRule = Get-SPEnterpriseSearchSiteHitRule -SearchService $params.ServiceAppName | Where-Object -FilterScript {$_.Site -eq $params.Name}

SharePoint version and build

SharePoint Server Subscription Edition 16.0.17928.20290

Operating system the target node is running

OsName               : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value                                                                                                                                                       
----                           -----                                                                                                                                                       
PSVersion                      5.1.20348.2849                                                                                                                                              
PSEdition                      Desktop                                                                                                                                                     
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                     
BuildVersion                   10.0.20348.2849                                                                                                                                             
CLRVersion                     4.0.30319.42000                                                                                                                                             
WSManStackVersion              3.0                                                                                                                                                         
PSRemotingProtocolVersion      2.3                                                                                                                                                         
SerializationVersion           1.1.0.1

SharePointDsc version

Name          Version Path                                                                             
----          ------- ----                                                                             
SharePointDSC 5.4.0   C:\Program Files\WindowsPowerShell\Modules\SharePointDSC\5.4.0\SharePointDSC.psd1
@ChristophHannappel
Copy link
Contributor Author

I'll create an PR to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant