Tagged: powershell

User Profile Synchronisation Errors In SharePoint 2013

After doing a SharePoint update at the weekend, I found that I couldn’t get the User Profile Sync to restart. It looked like it was getting to a point then failing, so I started checking the Event Viewer, found some errors and then found this article from Richard Skinner.

During testing of SharePoint 2013 I experienced the Application Event Log errors below. When the errors occurred I was unable to run a User Profile Synchronisation with Active Directory.

Event ID 6398, category Timer

The Execute method of job definition Microsoft.Office.Server.UserProfiles.UserProfileImportJob (ID 0afab701-a201-4df9-bfc7-590838da8809) threw an exception. More information is included below. Generic Failure

Event ID 1004, category None

Detection of product ‘{90150000-104C-0000-1000-0000000FF1CE}’, feature ‘PeopleILM’, component ‘{1C12B6E6-898C-4D58-9774-AAAFBDFE273C}’ failed. The resource ‘C:\Program Files\Microsoft Office Servers\15.0\Service\Microsoft.ResourceManagement.Service.exe’ does not exist.

Event ID 1001, category None

Detection of product ‘{90150000-104C-0000-1000-0000000FF1CE}’, feature ‘PeopleILM’ failed during request for component ‘{1681AE41-ADA8-4B70-BC11-98A5A4EDD046}’

The resolution is to grant read access to the Network Service account to the “C:\Program Files\Microsoft Office Servers\15.0” folder

PowerShell

$Acl = (Get-Item "E:\Microsoft Office Servers\15.0").GetAccessControl('Access')
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("NT AUTHORITY\NETWORK SERVICE","Read, ReadAndExecute, ListDirectory", "ContainerInherit, ObjectInherit", "None", "Allow")
$Acl.AddAccessRule($Ar)
Set-Acl "E:\Microsoft Office Servers\15.0" $Acl

Change Folder Content Type

Last week I had a request to add metadata to document library folders, thanks to this article (How to add a column to SharePoint folders) by Mike Smith I had the answer and before everyone starts I know you shouldn’t be using folders but it was the request.

Here the steps

  1. Go to Site Actions, Site Settings
  2. Click Site Content Types
  3. Click Create
  4. Give the new content type a name such as “Enhanced Folder”
  5. Set the parent content type group as Folder Content Types
  6. Set the parent content type to Folder
  7. Add the new content type to a Group. I put it back in the “Folder Content Types” group
  8. Click OK
  9. Scroll down to the columns section and click Add from new site column
  10. Name the column and set all the usual column options
  11. Repeat for any additional columns (Release Date, etc)
  12. Click OK
  13. Go to your document library
  14. Click Settings and Library Settings, or in 2010 click the Library ribbon tab and then click Library Settings
  15. Click Advanced and set Allow management of content types to Yes and click OK (this may already selected)
  16. Scroll down to Content Types and click Add from existing site content types and add your new folder content type
  17. Go to your library and click the New drop down, or the New button in the Document ribbon, and add your new folder!
  18. Go to the View drop down and click Modify this view and add your new folder meta data columns (you will probably want to move them to just after the Name column)

But, now I have my new content type, I had to update all the folders and sub folders with the new Enhanced Folder content type, PowerShell to the rescue.

$web = Get-SPWeb http://intranet/sites/test
$list = $web.Lists["Test"]
$oldCT = $list.ContentTypes["Folder"]
$newCT = $list.ContentTypes["Enhanced Folder"]
$newCTID = $newCT.ID

for($i=0; $i -le $web.Lists.Count; $i++)
{
   foreach($folder in $list.folders[$i])
   {
      if ($folder.ContentType.Name -eq $oldCT.Name)
      {
         $folder["ContentTypeId"] = $newCTID
         $folder.Update()
      }
   }
}

$web.Dispose()