Archive for April, 2011
SharePoint Central Admin error – “The specified user or domain group was not found”
Posted by Jake in SharePoint on April 7, 2011
While working with SharePoint Central Admin, I tried to access the Service Applications page (“Manage Service Applications” from Application Management). Before getting to the page, I received the error “The specified user or domain group was not found.” I checked the SharePoint logs and found this exception:
“SPAce PrincipalName domain\test.user cannot be resolved. This ACE will not be effective. System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.”
(For blogging, purposes, I am using the name “domain\test.user”) The Principal Name, “domain\test.user” happened to be an actual user that was no longer at the company. It appeared that this user, was being used for one of the service application administrators. I checked with Operations and indeed, “test.user” was purged from Exchange the day before. Working with operations, we recreated the same user name. We were unsure that this would work since the unique identifier of that user would be different, but it was worth a shot. After that user was added, I was able to access the Service Applications page again. Success!
The next step was to remove the user as an admin from the service application. For this situation, the User Profile service application was the problem. I accessed the Administrators dialog and removed the user from the list of admins.
The same user was also listed in the “Connections Permissions for User Profile Service Application.” I removed the user from that list as well.
With the user removed from the service application, Operations purged that user again. Afterward, I was able to access the Service Applications page without the error.
Powershell script for updating a publishing page Page Layout in a site collection
Posted by Jake in SharePoint on April 6, 2011
One of the page layout templates was changed in a SharePoint 2010 site collection that I was working on. There were already over 300 pages that were creating using the old Page Layout. Enter… Powershell! It took about two hours to write this script (with help from The Google) but it will probably save a day of work updating all those pages individually through the UI.
The script takes three parameters, the old or current page layout name, the new page layout name and an optional –all parameter which will traverse all the sites of a site collection. Enjoy.
# Description: # Update the layout page for all matching pages of the current page layout # Checkout, Change layout, Check-in pages in a site collection # # Syntax: # ./UpdateLayoutPages [-PageLayoutCurrent] [-PageLayoutNew] [-all] # # Parameters: # -PageLayoutCurrent - The page layout that is currently in use and will be updated # -PageLayoutNew - The new page layout that pages will be updated to # -all - Update subsites in the site collection # # Modifications: # v1.0 - April 5th, 2011 # Initial version # # Settings set-variable -option constant -name url -value http://localhost # Site collection set-variable -option constant -name comment -value "Batch PageLayout Update" # Publishing comment # Function: Update-SPPagesPageLayout # Description: Update a single page in a Publishing Web # Parameters: publishingPage, pageLayout, comment function Update-SPPagesPageLayout ([Microsoft.SharePoint.Publishing.PublishingPage]$publishingPage, [Microsoft.SharePoint.Publishing.PageLayout] $pageLayoutNew, [string]$comment) { Write-Host "Updating the page:" $publishingPage.Name "to Page Layout:" $pageLayoutNew.Title $publishingPage.CheckOut(); $publishingPage.Layout = $pageLayoutNew; $publishingPage.ListItem.Update(); $publishingPage.Update() $publishingPage.CheckIn($comment); if ($publishingPage.ListItem.ParentList.EnableModeration) { $publishingPage.ListItem.File.Approve("Publishing Page Layout correction"); } } # Function: Update-AllSPPagesPageLayouts # Description: Loop through all the pages in a Publishing Web and update their page layout # Parameters: web, pageLayoutCurrent, pageLayoutNew, comment # comment Comment to accompany the checkin Function Update-AllSPPagesPageLayouts ([Microsoft.SharePoint.SPWeb]$web, [Microsoft.SharePoint.Publishing.PageLayout]$pageLayoutCurrent, [Microsoft.SharePoint.Publishing.PageLayout]$pageLayoutNew, [string]$comment) { #Check if this is a publishing web if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web) -eq $true) { $pubweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web); $pubcollection=$pubweb.GetPublishingPages() #Go through all pages checking for pages with the "current" page layout for($i=0; $i -lt $pubcollection.count; $i++) { if($pubcollection[$i].Layout.Title -eq $pageLayoutCurrent.Title) { Update-SPPagesPageLayout $pubcollection[$i] $pageLayoutNew $comment } } } $web.Close(); } # Check Parameters if(($args[0] -ne $null) -and ($args[1] -ne $null)) { Write-Host "** Update Layout Pages from-" $args[0] "-to-" $args[1] "-on URL" $url $pageLayoutNameCurrent = $args[0]; $pageLayoutNameNew = $args[1]; $site = new-object Microsoft.SharePoint.Publishing.PublishingSite($url) Write-Host "Checking if both page layouts exist in the site..." # Check if the current pagelayout exists in this site collection $pageLayouts = $site.GetPageLayouts($true); $pageLayouts | ForEach-Object { if ($_.Title -eq $pageLayoutNameCurrent) { Write-Host "Found CURRENT page layout: " $pageLayoutNameCurrent $pageLayoutCurrent = $_; } } # Check if the new pagelayout exists in this site collection $pageLayouts | ForEach-Object { if ($_.Title -eq $pageLayoutNameNew) { Write-Host "Found NEW page layout: " $pageLayoutNameNew $pageLayoutNew = $_; } } # Do not continue if the either pageLayout does not exist if(($pageLayoutCurrent -ne $null) -and ($pageLayoutNew -ne $null)) { # Update all subsites if($args[2] -eq "-all") { $site.Site.allwebs | foreach { Write-Host "Checking Web: " $_.Title Update-AllSPPagesPageLayouts $_ $pageLayoutCurrent $pageLayoutNew $comment } } else { $site.rootweb | foreach { Write-Host "Checking Web: " $_.Title Update-AllSPPagesPageLayouts $_ $pageLayoutCurrent $pageLayoutNew $comment } } } Write-Host "**Done" } else { Write-Host "Missing arguments. Please check your parameters" } #End