0

Have run a PowerShell script to provision SPDistributedCacheService after running psconfig.(As I was Patching CU updates to 2016 SP farm) encountered this error:

PS C:\Users\***.admin> $InstanceName ="SPDistributedCacheService Name=AppFabricCachingService"
PS C:\Users\***.admin> $ServiceInstance = Get-SPServiceInstance | Where-Object {($PSItem.Service.ToString()) -eq $Ins
tanceName -and ($PSItem.Server.Name) -eq $env:COMPUTERNAME}
PS C:\Users\***.admin> $ServiceInstance.Provision()
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $ServiceInstance.Provision()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

how to resolve this error?

1

Try the following command to get SPDistributedCacheService.

$Service = Get-SPServiceInstance | where {$_.TypeName -eq "Distributed Cache"}
$Service.provision() 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.