Hi,
Using powershell script i ma trying to move search service from my id to farmSvcacct , but I am getting error
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Custom Function to change Service account of given service
Function Set-ServiceIdentity($svc, $UserName)
{
#Get the current service account
$ProcessIdentity = $svc.Service.ProcessIdentity
if ($ProcessIdentity.Username -ne $UserName)
{
$ProcessIdentity.Username = $UserName
$ProcessIdentity.Update()
Write-Host "Service Account Set!"
}
}
#Get the Service
$Service = Get-SPServiceInstance | Where {$_.TypeName -eq "Search Service Application"}
Set-ServiceIdentity $Service "Domain\farmSvcacct"
Below is the error i am getting please suggest, where i am doing mistake
Property 'Username' cannot be found on this object; make sure it exists and is settable.At Drive:\sfdfs\Test\change Service account of given service.ps1:13 char:8
+ $ProcessIdentity.Username = $UserName
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At Drive:\chdfdfh\Test\change Service account of given service.ps1:14 char:8
+ $ProcessIdentity.Update()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull