dsccommunity / dsccommunity/SharePointDsc

SPSearchServiceApp exception creating defaultAccount credential in Get-TargetResource

Open
#565 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug help wanted
Dominant language
C#
Stars
246
Forks
106
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you try and problem that is occurring:
During the last phase of my SP2016 DSC rollout, the SPSearchServiceApp resource is throwing an exception. The exception is:

PowerShell DSC resource MSFT_SPSearchServiceApp failed to execute Test-TargetResource functionality with error message: Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "userName" is not valid. Change the value of the "userName" argument and run the operation again."

I traced this down to line 94 in Get-TargetResource (the last line here):

$c = [Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($serviceApp.Name)
$sc = New-Object -TypeName Microsoft.Office.Server.Search.Administration.Content `
    -ArgumentList $c; 
$dummyPassword = ConvertTo-SecureString -String "-" -AsPlainText -Force 
$defaultAccount = New-Object -TypeName System.Management.Automation.PSCredential `
    -ArgumentList @($sc.DefaultGatheringAccount, $dummyPassword)

My resource block looks like this:

SPSearchServiceApp SearchServiceApp
{
    Name = 'Search Service Application'
    DatabaseName = 'SP_Search'
    DatabaseServer = 'SPSQL'
    ApplicationPool = $serviceAppPoolName
    DefaultContentAccessAccount = $ContentAccessAccount
    CloudIndex = $false
    PsDscRunAsCredential = $SPSetupAccount
    DependsOn = '[WaitForAll]WaitForMainServiceAppPool'
}

I'm going to try to replicate in my Azure lab to see if I get the same results, but wanted to go ahead and post this here to get some eyes on it in case I'm doing something wrong and/or there's an easy fix.

The DSC configuration that is using the resource:

Version of the Operating System and PowerShell the DSC Target Node is running:
WS2012R2; PS 5.1.14409.1005

Version of the DSC module you're using:
1.6.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the SPSearchServiceApp Get-TargetResource function, especially the credential construction at line 94, and reproduce the failure on the stated Windows Server 2012 R2, PowerShell 5.1, and SharePointDsc 1.6.0. Done means Test-TargetResource completes without the invalid userName exception for the provided resource configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.