Thursday, June 27, 2013

Project web app sites missing from Project Service Application


Recently I had a situation in which all the project web app sites were missing from the project service application in Central admin. I was not able to access them either. There were no errors in the event log or anywhere else. After a little poking around I found that all the databases associated with the project sites were still intact. Also, I could see the site collection in Central admin using the view all site collections link. So, luckily this was not a situation in which someone deleted all the project sites. With some relief, I started to look for a way to reattach the databases to the project service application.
My first try was to delete the site collection and create a new project web app site with the same site and database name. So, I backed up the project site collection and related databases and created a new project web app. Doing so resulted in following errors:

The database specified is already used by another project server. Enter a different server or database name and try again.

Next step was to clean up all the references to the project site using powershell

$serviceapp = get-spserviceapplication -name ""
$serviceapp.SiteCollection

Using the above commands, I got the Id of the project site collection and used it to remove the project web app site collection using the below commands

$projsite = $service.SiteCollection | ? {$_.Id -eq ""}
$projecsite.Delete()

Now that the project site was removed, I tried again to create a new project web app site with the same site and database names. Bingo, the site provisioned without any issues and was able to access the site again. All the contents were intact.


Thursday, December 06, 2012

Data at the root level is invalid. Line 1, position 1

Recently I exported a publishing sub-site from SharePoint 2010 and imported it as a site collection. After the import, the pages were displaying properly, but when I tried to add a new page, I got an error "Data at the root level is invalid. Line 1, position 1". I was also not able to edit the pages or access the "Page layouts and site templates" link from the site settings, both operations were failing.

Search on the web led me to http://blog.falchionconsulting.com/index.php/2007/09/convert-a-sub-site-to-a-site-collection/. As stated in the blog, I set the __PageLayouts property of the site collection to blank instead of "__inherit". Doing so allowed me to edit the page, but still was not able to create a new page or access the "Page layouts and site templates" page.

Next, I compared the property values of the site with the issue to a site collection that was working properly. I found property value of __DefaultPageLayout set to "__inhert", so I changed that to blank, still no luck. I continued the comparison process and found a property "__InheritCurrentNavigation" set to "True". This property was not present in the site collection that was working properly, so I deleted this property from the site collection, after doing so, I was able to add a new page and access the "Page layouts and site template" page.

I found few more properties (__IneritsAlternateCssUrl, __InheritsThemedCssFolderUrl, __InheritWebTemplates) that were present in the site collection with the problem, but were not present in the site collection that was working properly. To be safe I removed them as well.

Here is a summary of changes to the properties of the site collection:

__PageLayouts - set to blank
__DefaultPageLayout - set to blank
__InheritCurrentNavigation - delete
__IneritsAlternateCssUrl - delete
__InheritsThemedCssFolderUrl - delete
__InheritWebTemplates - delete

Wednesday, July 25, 2012

PowerShell script to add "Link to a Document" content type to all document libraries


$linkct = "Link to a Document"
$docct = "Document"
Get-SPSite -Limit all | Get-SPWeb -Limit all | ForEach-Object {
    
    $doclibtype =[Microsoft.SharePoint.SPBaseType]::DocumentLibrary
    $doclibs = $_.GetListsOfType($doclibtype)
    
    foreach ($doclib in $doclibs) 
    {
$newdoclib = $_.Lists[$doclib.ID]
    if ($newdoclib.AllowContentTypes)
          {
            $newdoclib.ContentTypesEnabled = $true
           $newdoclib.Update()
    
              #Add site content types to the list
      if (($newdoclib.ContentTypes[$linkct] -eq $null) -and
               ($newdoclib.ContentTypes[$docct] -ne $null))
      {
               $ctToAdd = $_.Site.RootWeb.ContentTypes[$linkct]
               $ct = $newdoclib.ContentTypes.Add($ctToAdd)
               "Content type " + $ct.Name + " added to list " + $newdoclib.Title
               $newdoclib.Update()
            }
         }
     }
}

SharePoint profile image sync issue.


The SharePoint farm I manage is configured to sync the pictures from SharePoint user profile to AD. Everything was working like a charm until we decided to upload pictures from an internal social media system in which users have profile images uploaded to SharePoint for users with no images in their profile.  I updated the pictures using a powershell script and ran Update-SPProfilePhotoStore command. I started getting the following errors in the event log and the Profile Synchronization Service manager:
Synchronization service Manager Error – MOSS_DELTAIMPORT_GUID stopped-extension-dll-exception
Event Log:
Event ID : 6801
Source: FIMSynchronizationService
The extensible extension returned an unsupported error.
 The stack trace is:

 "System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadData(Uri address)
   at Microsoft.Office.Server.UserProfiles.ManagementAgent.ProfileImportExportExtension.DownloadPictures(ProfileChangeData[] profiles)
   at Microsoft.Office.Server.UserProfiles.ManagementAgent.ProfileImportExportExtension.Microsoft.MetadirectoryServices.IMAExtensibleFileImport.GenerateImportFile(String fileName, String connectTo, String user, String password, ConfigParameterCollection configParameters, Boolean fFullImport, TypeDescriptionCollection types, String& customData)
Forefront Identity Manager 4.0.2450.34"

After trying multiple things and Googling, I came to the conclusion that the error was due to few rouge images which SharePoint could not convert. The problem was that I did not know the user with the problematic image. So, I first got a list of all images from “User Photo” library in the My Site host


$site = Get-spsite “http://mysitehost”
$web = $site.RootWeb
$list = $web.Lists["User Photos"]
$Folders = $list.RootFolder.SubFolders
foreach ($Folder in $Folders)
{
     if ($Folder.Name -ne "Forms")
     {          foreach ($item in $Folder.Files)           {               $item.Name          }     }
}
$web.Dispose();
$site.Dispose();

And then I listed down all users who had their profile images set using the script below:


$site = Get-SPSite "http://mysitehost " $ServiceContext = Get-SPServiceContext($site); $upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($servicecontext)$upm.GetEnumerator() | foreach{     $pictureURL = $_["PictureURL"].Value           if (($pictureURL -ne "") -and ($pictureURL -ne $null))           {                     $_["AccountName"].Value           }}


After manipulating the results from both the scripts using excel to find the unique user ids, I found that couple of users had their “PictureURL” property set but did not have the corresponding mthum.jpg, lthumb.jpg and sthumb.jpg files. I came to the conclusion that these were the users who had the offending images, since the system could not create the corresponding images from the source image.  Next, I set the “PictureURL” property for these 2 users to blank and started sync again. Viola, it synced the images without any issue.

Monday, March 05, 2012

The specified user or domain group was not found.

I started getting the error "The specified user or domain group was not found" after I restored a SP 2007 site to SP 2010 with claims authentication.

The event log had the above error followed by the following error:
Object Cache: The super reader account utilized by the cache does not have sufficient permissions to SharePoint databases.
To configure the account use the following command 'stsadm -o setproperty -propertyname portalsuperreaderaccount -propertyvalue account -url webappurl'. It should be configured to be an account that has Read access to the SharePoint databases.
Additional Data:
Current default super reader account: NT AUTHORITY\LOCAL SERVICE

To fix the error I had to run the following Power shell commands:
$wa = Get-SPWebApplication -Identity "http://yourwebapp"
$wa.Properties["portalsuperuseraccount"] = "domain\cacheuser"
$wa.Properties["portalsuperreaderaccount"] = "domain\cacheuser"
$wa.Update()

Thursday, October 13, 2011

Setting the search center Url for a site collection using powershell

$web = get-spweb “url of site collection”

$web.AllProperties["SRCH_ENH_FTR_URL"] = http://searchcenter/pages

$web.Update()

Moving a SharePoint site collection as a sub-site of another site collection

Moving a site collection to be a sub-site of another site collection can be achieved by exporting the site collection data and importing it as a sub-site.

Below are the steps:

  • Open up a SharePoint 2010 Management Shell
  • Execute the following PowerShell command to export the site collection

export-spweb “site collection url” -path “export filename” -includeusersecurity –includeversions All

  • Create a sub-site at the destination location with a blank site template
  • Execute the following PowerShell command to import the site collection to the sub-site

Import-spweb “sub-site url” -path “export file name”