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

SPSearchManagedProperty: Can't define Searchable #1288

Closed
rurikon opened this issue Feb 10, 2021 · 8 comments · Fixed by #1297
Closed

SPSearchManagedProperty: Can't define Searchable #1288

rurikon opened this issue Feb 10, 2021 · 8 comments · Fixed by #1297
Assignees
Labels
bug The issue is a bug. in progress The issue is being actively worked on by someone.

Comments

@rurikon
Copy link

rurikon commented Feb 10, 2021

Details of the scenario you tried and the problem that is occurring

I tried to add a search managed property. I wanted it to be searchable. This is the configuration I tried:

SPSearchManagedProperty TargetAudience
{
	ServiceAppName				= "Search Service Application"
	Name						= "TargetAudience"
	PropertyType				= "Text"
	Searchable					= $true
	Queryable					= $true
	Retrievable					= $true
	HasMultipleValues			= $true
	Refinable					= $true
	Sortable					= $true
	NoWordBreaker				= $false
	IncludeAllCrawledProperties	= $false
	Ensure						= "Present"
	PsDscRunAsCredential		= $SetupAccount
}

Running this goes smoothly, but trying Test-DscConfiguration will give an error (see below).

Without Searchable = $true there is no error in Test-DcsConfiguration, but still reports as "not in desired state". If I check Central Administration, the property has been created, but is not searchable.

Information from the node itself:

$status = Get-DscConfigurationStatus
$status.ResourcesNotInDesiredState

ConfigurationName    : SharePoint
ModuleName           : SharePointDSC
ModuleVersion        : 4.3.0
PsDscRunAsCredential :
ResourceId           : [SPSearchManagedProperty]TargetAudience
SourceInfo           : C:\xxxxxxxxxxxxxxx
DurationInSeconds    : 0,469
Error                :
FinalState           :
InDesiredState       : False
InitialState         :
InstanceName         : TargetAudience
RebootRequested      : False
ResourceName         : SPSearchManagedProperty
StartDate            : 10.2.2021 11.46.28
StateChanged         : False
PSComputerName       :

Verbose logs showing the problem

When running Test-DscConfiguration with Searchable = $true:

Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Searchable'  Key being added: 'Searchable'"
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : ArgumentException
    + PSComputerName        : xxxxxxxx

The PowerShell DSC resource '[SPSearchManagedProperty]TargetAudience' with SourceInfo 'C:\xxxxxxxx' threw one or more non-terminating errors while running the Test-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        : xxxxxxxxxxxxxxx

Suggested solution to the issue

N/A

The DSC configuration that is used to reproduce the issue (as detailed as possible)

See beginning.

The operating system the target node is running

N/A

Version and build of PowerShell the target node is running

PSVersion 5.1.14393.3866
BuildVersion 10.0.14393.3866

Version of the DSC module that was used

SharePointDSC 4.3.0

@rurikon
Copy link
Author

rurikon commented Feb 10, 2021

I later noticed that I was missing TokenNormalization = $true from the configuration, which is required for a property to be searchable. However, adding that didn't change the issue.

@ykuijs
Copy link
Member

ykuijs commented Feb 20, 2021

Hi @rurikon, just checked this issue and noticed that you specified "IncludeAllCrawledProperties = $false" in your config, but did not specify the CrawledProperties parameter. That is probably why the Test resource always returns false.

Can you please share the full verbose logging for this resource? That will give me more information on what goes wrong at which point.

@rurikon
Copy link
Author

rurikon commented Feb 22, 2021

I have left the CrawledProperties parameter out because of this issue: #1289 But I have also tried defining CrawledProperties and having IncludeAllCrawledProperties = $true, neither of those affect the error.

If Searchable is defined, the Test-DscConfiguration doesn't even execute, it just dies with the error "Item has already been added. Key in dictionary: 'Searchable' Key being added: 'Searchable'".

I included the full error in the "verbose logs" section above. If you want more, could you specify which ones you want?

@rurikon
Copy link
Author

rurikon commented Feb 22, 2021

dsc-searchable-error

Here is a screenshot for further clarification. Do you want me to look at the Event Viewer for details?

Now that I tested this again, I did notice that all properties don't give this error. The configurations are the same, though, except some are set as refinable or sortable and some are not, and it doesn't look like those settings play a role in this. And no, Searchable is not set twice, I was checking again and again when I first came across this.

@rurikon
Copy link
Author

rurikon commented Feb 23, 2021

The "all properties don't give this error" in the last comment bothered me, so I investigated more. I went through every property we have in the configuration and changed the Searchable value individually for each. It looks like every time I try to set Searchable = $true, it gives that error, and Searchable = $false goes through just fine without error.

@ykuijs
Copy link
Member

ykuijs commented Feb 23, 2021

Can you do another Test-DscConfiguration, but this time with the -Verbose parameter and share the outcome?

Based on the verbose logging, I can see where the issue is thrown, which makes troubleshooting much easier ;-)

@rurikon
Copy link
Author

rurikon commented Feb 23, 2021

Oh sorry, stupid me :) It doesn't give much more info, but here it is:

VERBOSE: [XXXXX]: LCM:  [ Start  Resource ]  [[SPSearchManagedProperty]TargetAudienceTest]
VERBOSE: [XXXXX]: LCM:  [ Start  Test     ]  [[SPSearchManagedProperty]TargetAudienceTest]
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Testing Managed Property Setting for 'TargetAudienceTest'
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Getting Managed Property Setting for 'TargetAudienceTest'
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Executing as the local run as user XXXXX
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Leaving BeginProcessing Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Leaving ProcessRecord Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Leaving EndProcessing Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Leaving BeginProcessing Method of Get-SPEnterpriseSearchMetadataManagedProperty.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Leaving ProcessRecord Method of Get-SPEnterpriseSearchMetadataManagedProperty.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Leaving EndProcessing Method of Get-SPEnterpriseSearchMetadataManagedProperty.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Current Values: Ensure=Absent; Name=TargetAudienceTest; PropertyType=Text; ServiceAppName=Search Service Application
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Target Values: Ensure=Present; HasMultipleValues=True; IncludeAllCrawledProperties=False; Name=TargetAudienceTest; NoWordBreaker=False; PropertyType=Text; Queryable=True; Refinable=True; Retrievable=True; Searchable=True; ServiceAppName=Search Service Application; Sortable=True; TokenNormalization=True; Verbose=True
Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'Searchable'  Key being added: 'Searchable'"
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : ArgumentException
    + PSComputerName        : XXXXX

VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudienceTest] Test-TargetResource returned False
VERBOSE: [XXXXX]: LCM:  [ End    Test     ]  [[SPSearchManagedProperty]TargetAudienceTest] False in 0.6090 seconds.
VERBOSE: [XXXXX]: LCM:  [ *FAILED*Compare  ]     Completed processing compare operation. The operation returned False.
The PowerShell DSC resource '[SPSearchManagedProperty]TargetAudienceTest' with SourceInfo 'C:\XXXXX::SPSearchManagedProperty' threw one or more non-terminating errors while running the Test-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        : XXXXX

VERBOSE: Operation 'Invoke CimMethod' complete.

We had to work on the actual property to get our project forward, so I went to Central Administration and manually checked the "Searchable" checkbox for the TargetAudience I created before. It might be relevant that after I manually checked it, the error disappeared for that property, even though it still has Searchable = $true. Here are the verbose logs for that one:

VERBOSE: [XXXXX]: LCM:  [ Start  Resource ]  [[SPSearchManagedProperty]TargetAudience]
VERBOSE: [XXXXX]: LCM:  [ Start  Test     ]  [[SPSearchManagedProperty]TargetAudience]
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Testing Managed Property Setting for 'TargetAudience'
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Getting Managed Property Setting for 'TargetAudience'
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Executing as the local run as user XXXXX
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Leaving BeginProcessing Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Leaving ProcessRecord Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Leaving EndProcessing Method of Get-SPEnterpriseSearchServiceApplication.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Leaving BeginProcessing Method of Get-SPEnterpriseSearchMetadataManagedProperty.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Leaving ProcessRecord Method of Get-SPEnterpriseSearchMetadataManagedProperty.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Leaving EndProcessing Method of Get-SPEnterpriseSearchMetadataManagedProperty.
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Current Values: Aliases=(); Ensure=Present; HasMultipleValues=True; IncludeAllCrawledProperties=True; Name=TargetAudience; NoWordBreaker=False; PropertyType=Text; Queryable=True; Refinable=True; Retrievable=True; SafeForAnonymous=False; Searchable=False; ServiceAppName=Search Service Application; Sortable=True; TokenNormalization=True
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Target Values: Ensure=Present; HasMultipleValues=True; IncludeAllCrawledProperties=False; Name=TargetAudience; NoWordBreaker=False; PropertyType=Text; Queryable=True; Refinable=True; Retrievable=True; ServiceAppName=Search Service Application; Sortable=True; TokenNormalization=True; Verbose=True
VERBOSE: [XXXXX]:                            [[SPSearchManagedProperty]TargetAudience] Test-TargetResource returned False
VERBOSE: [XXXXX]: LCM:  [ End    Test     ]  [[SPSearchManagedProperty]TargetAudience] False in 2.3280 seconds.
VERBOSE: [XXXXX]: LCM:  [ End    Resource ]  [[SPSearchManagedProperty]TargetAudience]

@ykuijs
Copy link
Member

ykuijs commented Mar 17, 2021

Hi @rurikon, I found the cause of this issue. Apparently it helps if you only check a property once 😜:

Will fix this issue in my next Bugfix PR, which will be included in v4.6.

@ykuijs ykuijs added bug The issue is a bug. in progress The issue is being actively worked on by someone. labels Mar 17, 2021
@ykuijs ykuijs self-assigned this Mar 17, 2021
ykuijs added a commit to ykuijs/SharePointDsc that referenced this issue Mar 17, 2021
@ykuijs ykuijs mentioned this issue Mar 17, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. in progress The issue is being actively worked on by someone.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants