Managed Metadata Service issue caused by SharePoint Feb 2015 CU

After applying the Feb CU to SharePoint environment, we experienced issues below:

(1) On the My Profile Edit page where all the term set properties are getting the following error:

There was a problem retrieving data for this field. Updating values in this field is disabled temporarily. You can still update values in other fields.

(2) Also, if you’re trying to enter a hashtag when posting a newsfeed, you’ll get

The tagging service is currently unavailable, Please try again later.

To Fix the issues, you have to do the following:

1. Open a Command Prompt window using Farm account and at the command prompt, type:

cd /d %commonprogramfiles%\Microsoft Shared\Web server extensions\15\BIN

2. Fix the permissions on the server by entering the following command:

psconfig -cmd secureresources

3. Restart IIS and make the changes by entering the following command at the command prompt:
iisreset /noforce

 

Configure continuous crawl interval using Powershell in SharePoint 2013

A continuous crawl crawls content that was added, changed, or deleted since the last crawl. Unlike an incremental crawl, which starts at a particular time and repeats regularly at specified times after that, a continuous crawl automatically starts at predefined time intervals. The default interval for continuous crawls is every 15 minutes.
Update: Continuous Crawl doesn’t work for People search (users update their profile values). The workaround is to create a separate content source for People and set up Incremental Crawl every 15 – 30 minutes.
To Enable Continuous Crawls:
$ssa = Get-SPEnterpriseSearchServiceApplication
$contentsource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $ssa -Identity "Local SharePoint sites"
Set-SPEnterpriseSearchCrawlContentSource -Identity $contentsource -EnableContinuousCrawls $True
To Disable Continuous Crawls:
$ssa = Get-SPEnterpriseSearchServiceApplication
$contentsource = Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $ssa -Identity "Local SharePoint sites"
Set-SPEnterpriseSearchCrawlContentSource -Identity $contentsource -EnableContinuousCrawls $False
To get the continuous crawl interval:
############# Get the Continuous Crawl Interval in SharePoint 2013 ############# 
$ssa = Get-SPEnterpriseSearchServiceApplication
$ssa.GetProperty("ContinuousCrawlInterval")

To set the continuous crawl interval:
############# Set the Continuous Crawl Interval in SharePoint 2013 ############# 
$ssa = Get-SPEnterpriseSearchServiceApplication
$ssa.GetProperty("ContinuousCrawlInterval",20)

Change Newsfeed setting of all User profiles in SharePoint 2010 – Part 1

In SharePoint 2010, Newsfeed provides fancy functionality, which allows user to keep well socializing inside of organization:

My Newsfeed is the default page when a user accesses his or her My Site. This section displays the What’s New page, which provides a feed of recent activities related to a user’s specified colleagues and interests. Users can customize their newsfeeds by adding or removing colleagues they are interested in, specifying interests, and configuring the kind of activities they want to follow, such as when a colleague tags information with a shared interest. (MSDN http://technet.microsoft.com/en-us/library/ff382643.aspx)

Compare to Interests and Email Notification, “Activities I am following” does not have a mapping property in the Central Admin. I just encountered a client requirement last week, who wants to initialize the activity events for all the users; in other words, some of items in the section will be unchecked.

The above section of activities is extensible through object model and hence you can expect more items to appear under this list of activities one can follow. The modification to each user activities is stored under ActivityPreference in the profile database.

Below is PowerShell script to change Newsfeed setting.

NOTE: I have not found a solution to initialize the checkbox automatically when a new user profile is created. 

*** I have a solution for new user in my second post Change Newsfeed setting of all User profiles in SharePoint 2010 – Part 2

##########################   XML file : ConfigActivityFeed.xml ############################

<?xml version="1.0" encoding="utf-8" ?>
<ActivityTypes>
     <URL>http://dev.mysite.com/</URL>
     <ActivityType Name="StatusMessage" IsSet="True"></ActivityType>
     <ActivityType Name="SocialTaggingByAnyone" IsSet="False"></ActivityType>
     <ActivityType Name="SocialRatings" IsSet="True"></ActivityType>
     <ActivityType Name="DLMembershipChange" IsSet="True"></ActivityType>
     <ActivityType Name="SharingInterest" IsSet="True"></ActivityType>
     <ActivityType Name="SocialTaggingByColleague" IsSet="True"></ActivityType>
     <ActivityType Name="NoteboardPosts" IsSet="True"></ActivityType>
     <ActivityType Name="TitleChange" IsSet="True"></ActivityType>
     <ActivityType Name="ManagerChange" IsSet="False"></ActivityType>
     <ActivityType Name="BlogUpdate" IsSet="True"></ActivityType>
     <ActivityType Name="WorkplaceAnniversary_Reminder" IsSet="False"></ActivityType>
     <ActivityType Name="WorkplaceAnniversary_Today" IsSet="False"></ActivityType>
     <ActivityType Name="ColleagueAddition" IsSet="True"></ActivityType>
     <ActivityType Name="ProfilePropertyChange" IsSet="True"></ActivityType>
     <ActivityType Name="Birthday_Reminder" IsSet="False"></ActivityType>
     <ActivityType Name="Birthday_Today" IsSet="False"></ActivityType>
</ActivityTypes>

#######################   ConfigActivityFeed.ps1 ###############################

#----------------Get the xml file---------------------------------------------------------------

[xml]$xmlData=Get-Content "ConfigActivityFeed.xml"

#----------------Set Activity Feed Preferences--------------------------------------------------
function SetActivityFeed
{
Param(
[Microsoft.Office.Server.ActivityFeed.ActivityManager]$UserActivityManager,
[string]$User
)

#---------------------------------------------------------------------------------------------------------
try
{
   $apptList = New-Object System.Collections.Generic.List[Microsoft.Office.Server.ActivityFeed.ActivityPreferencePerType]
   $appts = $UserActivityManager.ActivityPreferences.GetActivityPreferencesPerType()

   $ats = $UserActivityManager.ActivityTypes

   $User >> ".\ActivityTypeName.txt"

   foreach($appt in $appts)
   {
      $appt.ActivityType.ActivityTypeName >> ".\ActivityTypeName.txt"
 #----------------------------------------------------------------------------------
 # IsSet -> indicating whether a user wants to see the ActivityType object stored
 # in this ActivityPreferencePerType in a feed
 #----------------------------------------------------------------------------------
      $appt.IsSet >> ".\ActivityTypeName.txt"
 #----------------------------------------------
 # Change the value of IsSet to check/uncheck
 #----------------------------------------------
      $xmlData.ActivityTypes.ActivityType | ForEach-Object{
         $typeName = $_.Name
         if($appt.ActivityType.ActivityTypeName.Equals($typeName))
         {
            $appt.IsSet = [System.Convert]::ToBoolean($_.IsSet)
         #write-host -f red "Check ActivityType: " $appt.ActivityType.ActivityTypeName}
         } 
      }
      $apptList.Add($appt)

   } 
### Display value of properties
<#
 foreach($type in $ats)
 {
 write-host -f green "ActivityTypeNameLocStringName:" $type.ActivityTypeNameLocStringName
 write-host -f blue "ActivityTypeNameLocStringResourceFile:" $type.ActivityTypeNameLocStringResourceFile
 write-host "ApplicationId:" $type.ApplicationId
 }
 #>
}
catch
{
   Get-Date >> ".\ActivityFeedErrLog.txt"
   $_.Exception.ToString() >> ".\ActivityFeedErrLog.txt"
}

$line = "--------------------------------------"
$line >> ".\ActivityTypeName.txt"
### Sets the current user's preferences for each ActivityType object managed by the ActivityManager
$UserActivityManager.ActivityPreferences.SetActivityPreferencesPerType($apptList)
$UserActivityManager.ActivityPreferences.Commit()
$UserActivityManager.ActivityPreferences.Refresh()

}

#----------------Get Activity Manager with specific user account------------------------------------------
function ConfigActivityFeed()
{
   $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
   if ($snapin -eq $null)
   {
      Write-Host "`nLoading SharePoint Powershell Snapin`n"
      Add-PSSnapin "Microsoft.SharePoint.Powershell"
   }

Try
{
   $site = Get-SPSite $xmlData.ActivityTypes.URL
   $context = Get-SPServiceContext($site)
 ### Get User Profile
   $upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

   [void][System.Reflection.Assembly]::LoadWithPartialName("System")
   $user = $upm.GetUserProfile("ad\lixuan0125")
 ### Iterate all the user profiles
 <#[System.Collections.IEnumerator] $en = $upm.GetEnumerator()
 while($en.MoveNext())
 {
 $user = [Microsoft.Office.Server.UserProfiles.UserProfile]($en.Current)
 $str = [Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName
 $userName = $user[$str].Value.ToString()
 write-host -f blue $userName
 #>
 ### Get Activity Feed Manager
    $am = New-Object Microsoft.Office.Server.ActivityFeed.ActivityManager($user, $context)

 ### Using reflection to set preference for user; otherwise, only get preference of account which is used to login server
    $methodInfo = $am.GetType().GetMethod("CopyBasicUserInfo", [reflection.bindingflags]"nonpublic,instance", $null, $user.GetType(), $null)
 ### Invokes the method represented by the current object instance, using the specified parameters
 ### Invoke(Object obj, Object[] parameters)
    $methodInfo.Invoke($am, $user)

    SetActivityFeed -UserActivityManager $am -User $userName
 #}
}
Catch
{
   write-error $_.Exception
   Get-Date >> ".\ActivityFeedErrLog.txt"
   $_.Exception.ToString() >> ".\ActivityFeedErrLog.txt"
}

write-host -f red "Done"
$site.Dispose()

}

#----- Call function ---

ConfigActivityFeed
Start-Sleep -Seconds 50;

Deploy and Upgrade SharePoint solution with PowerShell script

/*----------- Package information in XML file : package.xml -------------------*/
<?xml version="1.0" encoding="utf-8"?>
<project>
<packages>
<package name="SharePoint.Communities.BrandingMySite.wspliteralPath="./SharePoint.Communities.BrandingMySite.wsp"
deploysTo="global"/>
</packages>
</project>

/*------------------- Deploy Solution : deployMySite.ps1 ----------------------*/
function Provision-InitialStructure([string]$configFilePath)
{
   #### Get SharePoint PowerShell ####

   $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
{
Write-Host "`nLoading SharePoint Powershell Snapin`n"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}


Write-Host "****************************************************************"
Write-Host "*                                                              *"
Write-Host "* Deploying My Site Solution - Globally                        *"
Write-Host "*                                                              *"
Write-Host "****************************************************************"


write-host "`nParsing config file`n";


[System.Xml.XmlDocument] $xd = new-object System.Xml.XmlDocument;
$file = resolve-path($configFilePath);
$xd.load($file);


###### ADD SOLUTION PACKAGES TO SHAREPOINT SOLUTION STORE ##########


$packages = $xd.selectnodes("project/packages/package");


foreach ($package in $packages)
{
$pkg_name = $package.getAttribute("name");
$pkg_literalpath = $package.getAttribute("literalPath");
$pkg_deploysto = $package.getAttribute("deploysTo");


$packageexists = (Get-SPSolution $pkg_name -ErrorAction SilentlyContinue) -ne $null;

if ($packageexists)
{
Write-Host -ForegroundColor Red "Solution already exist in solution store.";
return;
}
else
{
Write-Host "Adding solution package $pkg_name to Solution Store ..."
Add-SPSolution -LiteralPath $pkg_literalpath
Write-Host "`nDone. Deploying solution package ...`n"
Install-SPSolution -Identity $pkg_name -GACDeployment –force
}
}
Start-Sleep -Seconds 10;

###### END ADD SOLUTION PACKAGES TO SHAREPOINT SOLUTION STORE ##########
} #end function


# call the function
Provision-InitialStructure ./package.xml
Start-Sleep -Seconds 40;

/*------------------------ Upgrade Solution --------------------------*/

if ($packageexists)
{
Write-Host "Updating solution package $pkg_name to Solution Store ..."
Update-SPSolution -Identity $pkg_name -LiteralPath $pkg_literalpath -GACDeployment - ErrorAction Inquire;
}
else
{
Write-Host -ForegroundColor Red "Solution doesn't exist in solution store.";
return;
}

Config User Profile Properties using PowerShell Script

*******************SetUserProfileProperty.xml*******************************************

<?xml version=”1.0″ encoding=”utf-8″ ?>
<UserProfileProperty>
<URL>http://dev.mysite.com/</URL&gt;
<Property Name=”SPS-JobTitle” IsVisibleOnEditor=”True”></Property>
<Property Name=”SPS-Skills” UserOverride=”True” IsVisibleOnEditor=”True” IsVisibleOnViewer=”True”></Property>
<Property Name=”SPS-PastProjects” UserOverride=”True” IsVisibleOnEditor=”True” IsVisibleOnViewer=”True”></Property>
<Property Name=”TransitRollup” Privacy=”Public” IsVisibleOnEditor=”True” IsVisibleOnViewer=”True”></Property>
<Property Name=”TransitNumber” Privacy=”Public” IsVisibleOnEditor=”True” IsVisibleOnViewer=”True”></Property>
</UserProfileProperty>

*******************SetUserProfileProperty.ps1*******************************************

#—————-Get the xml file—————————————————————

[xml]$xmlData=Get-Content “SetUserProfileProperty.xml”

#—————-Set Privacy Policies for User Profile properties———————————————
function ConfigUserProfileProperty()
{
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq ‘Microsoft.SharePoint.Powershell’} 
if ($snapin -eq $null)
{
Write-Host “`nLoading SharePoint Powershell Snapin`n”
Add-PSSnapin “Microsoft.SharePoint.Powershell”
}

Write-Host “****************************************************************”
Write-Host “*                                           Configure User Profile Property                                     *”
Write-Host “****************************************************************`n”

$site = Get-SPSite $xmlData.UserProfileProperty.URL
$context = Get-SPServiceContext($site)

 #—————–Create a new object of UserProfileConfigManager—————————-#
[Microsoft.Office.Server.UserProfiles.UserProfileConfigManager] $upcm = new-object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context);
$pm = $upcm.ProfilePropertyManager

#—————–Create a new object of ProfileSubTypeManager—————————-#

$psm = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($context)
$p = $pm.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
$ps = $psm.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User))

#—————–Create a new object of ConnectionManger—————————-#

[Microsoft.Office.Server.UserProfiles.ConnectionManager] $cm = $upcm.ConnectionManger
[Microsoft.Office.Server.UserProfiles.PropertyMapCollection] $pmc = $cm[“AD Domain”].PropertyMapping
$pspm = $ps.Properties
$xmlData.UserProfileProperty.Property | ForEach-Object{
$sproperty = $pspm.GetPropertyByName($_.Name)
$property = $p.GetPropertyByName($_.Name)
if($property -ne $null)
{
#### Update Defaul Privacy
$Privacy=$_.Privacy
if($Privacy -ne $null)
{
$sproperty.DefaultPrivacy = [Microsoft.Office.Server.UserProfiles.Privacy]::$Privacy
}

#### Update UserOverridePrivacy
$UserOverride=$_.UserOverride
if($UserOverride -ne $null)
{
$sproperty.UserOverridePrivacy = [System.Convert]::ToBoolean($UserOverride)
}
write-host -f yellow $_.Name “: set allow user override privacy to” $sproperty.UserOverridePrivacy “`n”
$sproperty.Commit();
Start-Sleep -Seconds 1;

#### Update Show on the Edit Detail Page
$IsVisibleOnEditor=$_.IsVisibleOnEditor
if($IsVisibleOnEditor -ne $null)
{
$property.IsVisibleOnEditor = [System.Convert]::ToBoolean($IsVisibleOnEditor)
}
write-host -f yellow $_.Name “: set show on the edit detail page to” $property.IsVisibleOnEditor “`n”
Start-Sleep -Seconds 1;

#### Update Show in the Profile Properties Section of the user’s profile page
$IsVisibleOnViewer=$_.IsVisibleOnViewer
if($IsVisibleOnViewer -ne $null)
{
$property.IsVisibleOnViewer = [System.Convert]::ToBoolean($IsVisibleOnViewer)
}
write-host -f yellow $_.Name “: set show in the profile properties section of the user’s profile page to” $property.IsVisibleOnViewer “`n”
Start-Sleep -Seconds 1;

$property.Commit()
write-host -f green $_.Name “property settings are modified successfully `n”
Start-Sleep -Seconds 2;
}
else
{
write-host -f red $_.Name property does not exists
}
}
Start-Sleep -Seconds 5;

####Add new mapping####

if($pmc["propertyname"].DataSourcePropertyName -ne "fieldnameInAD")
{
#---Add new mapping will replace the original one,use same function for change mapping
$pmc.AddNewMapping([Microsoft.Office.Server.UserProfiles.ProfileType]::User, "propertyname", "fieldnameInAD")
}

$site.Dispose()

} #— end of function—

#—————-Calling the function———————————————

ConfigUserProfileProperty
write-host -f Magenta “Finished”
Start-Sleep -Seconds 50;