UserProfileApplication.SynchronizeMIIS: Failed to configure ILM, will attempt during next rerun. Exception: System.Data.SqlClient.SqlException

RUN AS FARMADMIN!!!!!

 

$sync_db = "PROD_SA_UPS_Sync"

$ups_service_app_name = "User Profile Service"

 

 

 

net stop sptimerv4

$syncdb=Get-SPDatabase | where {$_.Name -eq $sync_db}

$syncdb.Unprovision()

$syncdb.Status='Offline'

$ups = Get-SPServiceApplication  | where {$_.Displayname -eq $ups_service_app_name }

$ups.ResetSynchronizationMachine()

$ups.ResetSynchronizationDatabase()

$syncdb.Provision()

net start sptimerv4

 

Start the UserProfileSyncService again