Monthly Archives: February 2015

SharePoint: Script to update User information from AD

Published / by / Leave a Comment

In SharePoint some of the user information is stored at the site collection level in user information list (_catalogs/users/simple.aspx). User name and other changes are not synchronized with User profile information  (user last name changed, not updated at site level). The below script can be used to update it at all the site collection.


function Sync-SPUser([string]$userName) {

Get-SPSite -Limit All | foreach {
$web = $_.RootWeb
$user = $web | Get-SPUser -Identity $userName -ErrorAction SilentlyContinue
if ($user -ne $null)
$web | Set-SPUser -Identity $user -SyncFromAD
$path = “D:\Temp\Greg_User_sites.txt”
$web.Url | Out-File -FilePath $path -Append

Sync-SPUser “Contoso\Admin”

Can’t start User Profile Synchronization service in SharePoint 2013 – UnauthorizedAccessException

Published / by / Leave a Comment

Error from Log Files

Exception trying to write the management agent stack size for the Moss MA. System.UnauthorizedAccessException: Access to the registry key ‘HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\FIMSynchronizationService\Parameters\PerMAInstance\MOSS-UserProfile’ is denied.
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.CreateSubKeyInternal(String subkey, RegistryKeyPermissionCheck permissionCheck, Object registrySecurityObj, RegistryOptions registryOptions)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey, RegistryKeyPermissionCheck permissionCheck)
at Microsoft.Office.Server.Administration.UserProfileApplication.SetupSynchronizationService(ProfileSynchronizationServiceInstance profileSyncInstance)


  • Go to Central Admin -> Security -> Service Accounts
  • Find the account running “User Profile Synchronization Service”
  • Add the account as admin on the servers
  • Restart the servers