Error in Enterprise search function? (2.5)

Jun 17, 2011 at 7:59 AM
Edited Jun 17, 2011 at 8:15 AM

Hey!

Using the very latest version, I have found something I think is an error:

We are not installing Enterprise search as part of our setup, because we use FAST.
So, I'm setting Provision=false

I haven't configured anything in that node, and it failed and failed and failed, so I looked at the code, and the IF sentence (checking to se if it should provision) has an ELSE statement, where all sorts of parameters from the EnterpriserSearch XML node is used - that surely must be an error?

If I set provision=false, then it should do nothing, right?

It fails here:

	Else
	{
		WriteLine
		#Set the service account to something other than Local System to avoid Health Analyzer warnings
	    $svcConfig = $xmlinput.Configuration.ServiceApps.EnterpriseSearchService
		$secSearchServicePassword = ConvertTo-SecureString -String $svcConfig.Password -AsPlainText -Force
		If (($svcConfig.Account) -and ($secSearchServicePassword))
		{
    		# Use the values for Search Service account and password, if they've been defined
			$username = $svcConfig.Account
			$password = $secSearchServicePassword
		}
		Else
		{
			$spservice = $xmlinput.Configuration.Farm.ManagedAccounts.ManagedAccount | Where-Object { $_.CommonName -match "spservice" }
			$username = $spservice.username
			$password =  ConvertTo-SecureString "$($spservice.password)" -AsPlaintext -Force
		}
		Write-Host -ForegroundColor White " - Applying service account $username to Search Service..."
		Get-SPEnterpriseSearchService | Set-SPEnterpriseSearchService -ServiceAccount $username -ServicePassword $password
		If (!$?) {Write-Error " - An error occurred setting the Search Service account!"}
		WriteLine
	}

And it is the line ($secSearchServicePassword = ConvertTo-SecureString -String $svcConfig.Password -AsPlainText -Force) that fails - because I haven't put anything into those parameters!
Should I do that? seems strange that I have to fll out something I dont intent on using.

Maybe It should read:

	else
	{
		WriteLine
		#Set the service account to something other than Local System to avoid Health Analyzer warnings
	    $svcConfig = $xmlinput.Configuration.ServiceApps.EnterpriseSearchService
		
		If ((![string]::IsNullOrEmpty($svcConfig.Account)) -and (![string]::IsNullOrEmpty($svcConfig.Password)))
		{
			$secSearchServicePassword = ConvertTo-SecureString -String $svcConfig.Password -AsPlainText -Force
    		# Use the values for Search Service account and password, if they've been defined
			$username = $svcConfig.Account
			$password = $secSearchServicePassword
		}
		Else
		{
			$spservice = $xmlinput.Configuration.Farm.ManagedAccounts.ManagedAccount | Where-Object { $_.CommonName -match "spservice" }
			$username = $spservice.username
			$password =  ConvertTo-SecureString "$($spservice.password)" -AsPlaintext -Force
		}
		Write-Host -ForegroundColor White " - Applying service account $username to Search Service..."
		Get-SPEnterpriseSearchService | Set-SPEnterpriseSearchService -ServiceAccount $username -ServicePassword $password
		If (!$?) {Write-Error " - An error occurred setting the Search Service account!"}
		WriteLine
	}

That works...

Cheers
Jesper

Coordinator
Jun 17, 2011 at 11:09 AM

You're right, we shouldn't have to enter information for a service app or section you don't intend to use. I'll implement some checking here as you suggested!

Brian

Coordinator
Jun 17, 2011 at 11:09 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.