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: Set-TargetRessource uses SearchServiceApplicationPipeBind instead of SearchServicePipeBind and it throws #1446

Open
ChristophHannappel opened this issue Jan 20, 2025 · 0 comments

Comments

@ChristophHannappel
Copy link
Contributor

Problem description

The -SearchService Parameter SPEnterpriseSearchSiteHitRule Command expects an "Microsoft.Office.Server.Search.Cmdlet.SearchServicePipeBind" Object and not a "Microsoft.Office.Server.Search.Cmdlet.SearchServiceApplicationPipeBind"

Get-Command -Name 'New-SPEnterpriseSearchSiteHitRule' -Syntax
New-SPEnterpriseSearchSiteHitRule [-Name] <string> -HitRate <string> -Behavior <string> [-SearchService <SearchServicePipeBind>] [-Assignment
Collection <SPAssignmentCollection>] [-WhatIf] [-Confirm] [<CommonParameters>]

Currently the Service Service Application is passed and the cmdlet throws an exception.

Verbose logs

New-SPEnterpriseSearchSiteHitRule : Cannot bind parameter 'SearchService'. Cannot convert the "SearchServiceApplication 
Name=SearchService_Default" value of type "Microsoft.Office.Server.Search.Administration.SearchServiceApplication" to type 
"Microsoft.Office.Server.Search.Cmdlet.SearchServicePipeBind".

DSC configuration

Configuration Example
{
    param
    (
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $SetupAccount
    )

    Import-DscResource -ModuleName SharePointDsc

    node localhost
    {
        SPSearchCrawlerImpactRule IntranetCrawlerImpactRequestLimitRule
        {
            ServiceAppName       = "Search Service Application"
            Name                 = "https://intranet.sharepoint.contoso.com"
            RequestLimit         = 8
            Ensure               = "Present"
            PsDscRunAsCredential = $SetupAccount
        }
    }
}

Suggested solution

$serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName
if ($null -eq $serviceApp)
{
$message = "The Search Service Application does not exist."
Add-SPDscEvent -Message $message `
-EntryType 'Error' `
-EventID 100 `
-Source $eventSource
throw $message
}
New-SPEnterpriseSearchSiteHitRule -Name $params.Name `
-Behavior $behavior `
-HitRate $hitRate `
-SearchService $serviceApp
}

On Line 160 the Search Service Application is stored into the Variable $serviceApp and then passed to the Parameter -SearchService

There are three approaches to this:

  1. Pass the Name Property of the Search Service Application, which gets converted to the right Search Service.
$serviceApp = Get-SPEnterpriseSearchServiceApplication -Identity $params.ServiceAppName | Select-Object -ExpandProperty Name
  1. Just pass the Service Application Name from the ressource via $params.ServiceAppName
  2. Remove the ServiceAppName Parameter from the Ressource and replace the Get-SPEnterpriseSearchServiceApplication with Get-SPEnterpriseSearchService.
    As far as i know you are not able to create additional "Service Services" - so i don't think this needs to be configurable.
    The Resource was added with v3.8.0 and had this issue ever since, but removing the Parameter would result in a breaking Change.

SharePoint version and build

SharePoint Server 2016 and SE

Operating system the target node is running

OsName               : Microsoft Windows Server 2016 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsBuildLabEx    : 14393.7604.amd64fre.rs1_release.241127-1746
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value                                                                                                        
----                           -----                                                                                                        
PSVersion                      5.1.14393.7604                                                                                               
PSEdition                      Desktop                                                                                                      
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                      
BuildVersion                   10.0.14393.7604                                                                                              
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
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

No branches or pull requests

1 participant