Yesterday I had an issue reconfiguring the User Profiles Service Application where got “Operation is not valid due to the current state of the object”

Profile Synchronisation

My customer used SharePoint Active Directory Import and we needed to switch this to SharePoint Profile Synchronisation.


Why? We wanted to import  photos stored in AD into the SharePoint User Profiles using PowerShell. And the

Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation https:/ /mysite

is only supported with profile synchronisation.

First of all I got these messages when I switched the synchronisation type. Every minute a number of these appeared.

PartitionPropertiesCache.RefreshPartitionProperties: Encountered error: System.InvalidOperationException: Operation is not valid due to the current state of the object. ;at
Microsoft.Office.Server.Administration.UserProfileApplication.PartitionPropertiesCache.get_SqlSession() ;at Microsoft.Office.Server.Administration.UserProfileApplication.PartitionPropertiesCache.RefreshPartitionProperties()

I looked at:

  • FIM certificates
  • Try to run the sync on a different server
  • Checked the account used in the services console?
  • Checked for stuck timer jobs?
  • Recreated the user profile service (many times)

None of this worked.

Then I found some additional errors:

User Profile Application: SynchronizeMIIS encounters an exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Office.Server.UserProfiles.UserProfileImportJob.<>c__DisplayClass2.b__1()
at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.b__3()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
at Microsoft.Office.Server.UserProfiles.UserProfileImportJob.IsTimerJobRunning(UserProfileApplicationJob timerJob)
at Microsoft.Office.Server.Administration.UserProfileApplication.SynchronizeMIIS()
at Microsoft.Office.Server.Administration.ILMProfileSynchronizationJob.Execute()

Also of the two services involved I found that the Synchronisation Service was stuck in starting

User Profile Service                                    Started    Stop
User Profile Synchronization Service     Starting

Fixing Operation is not valid due to the current state of the object

Then I started to play around with some PowerShell.

Add-PSSnapin “Microsoft.SharePoint.PowerShell”

Get-SPServiceInstance | where {$_.TypeName -like “User*”}

This usually returns:

TypeName Status Id
——– —— —
User Profile Synchronization … Online e2212408-5988-439f-9784-db085650e9ac
User Profile Service Online c0b2cca4-f440-43f6-8018-d32b0547eb31

In my case I found that I got 4 services returned.

So for all for services I ran :

Stop-SPServiceInstance <Guid>

Then I started the User Profile Service (in my case both instances)

Start-SPServiceInstance <Guid>

Then I started one of the synchronisation services and all started to work.

Conclusion there must have been a left over user profile service causing problems.

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.