SharePoint Dragons

Nikander & Margriet on SharePoint

Quick Tip for Testing Load Balancing in SharePoint 2013

Adjust the SharePoint Master page on each WFE and add an HTML comment to it such as: <!—WFE 1 –>, and <!—WFE 2 –>. Yes, we know that’s not supported in production, but if you don’t dare to try minor stuff like that when the situation calls for it, you’re just lacking courage ;-) ! We’ve added this tip and more to the Troubleshooting section of the SharePoint 2013 Best Practices page at http://social.technet.microsoft.com/wiki/contents/articles/12438.sharepoint-2013-best-practices.aspx#Troubleshooting

SharePoint 2013 Upgrade and Migration Best Practices

Where are the SharePoint 2013 Search Suggestions?

What to do when search suggestions don’t show up? Run the “prepare query suggestions” timer job!

If you set up search suggestions (as described in http://technet.microsoft.com/en-us/library/jj721441.aspx ) you may notice that no suggestions drop down from the search bar. That makes sense, because they only appear after the “prepare query suggestion” timer job has run. You can force this via PowerShell like this:

Start-SPTimerJob -Identity “prepare query suggestions”

We’ve added the following TechNet Wiki page that describes how to do that: http://social.technet.microsoft.com/wiki/contents/articles/16640.sharepoint-2013-tips-for-troubleshooting-search-suggestions.aspx It will contain any updates to this tip.

Credits

Based on the content of: http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/33265dfd-1316-4c57-92b9-31f0d8f0078c

Add a multivalued taxonomy field to the default view in a custom list thru PowerShell

The title says it all, really. There was one particularly tricky part, where the view needed to be stored in a separate variable, like so:

$view = $myCustomList.DefaultView

Because $myCustomList.DefaultView resulted in the creation of a new View object every time, causing any changes you made to a previous object instance to be lost. The code is here, and it requires you to set up a managed metadata service instance (ours is called Managed Metadata Service), the following blog post can help you with that: http://chakkaradeep.com/index.php/sharepoint-2010-content-type-hubs-publish-and-subscribe-to-content-types/

$TestSiteUrl = “http://demosrv/sites/Wilmie”
$Web = Get-SPWeb -identity $TestSiteUrl

#Dev: remove list and create it every time anew
$List = $Web.Lists["CustList"]
$List.Delete()

$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::GenericList
$lstId = $Web.Lists.Add(“CustList”,”Cust Descr”,$listTemplate)
write-host “list ” $ListName ” created successfully” $ListName -ForegroundColor Green  

$myCustomList = $Web.Lists["CustList"]

#Example simple text field (without taxonomy field, this makes testing easier)
#$firstNameColXml = “<Field Type=’Text’ DisplayName=’FirstName’ Required=’TRUE’ MaxLength=’255′ StaticName=’FirstName’ Name=’FirstName’ />”
#$myCustomList.Fields.AddFieldAsXml($firstNameColXml,$true, [Microsoft.SharePoint.SPAddFieldOptions]::AddFieldToDefaultView)  
#$myCustomList.Update()

$taxonomySite = Get-SPSite “http://demosrv:1971″
$taxonomySession = Get-SPTaxonomySession -site $taxonomySite
$termStore = $taxonomySession.TermStores["Managed Metadata Service"]
write-host “Connection made with term store -”$termStore.Name
$termStoreGroup = $termStore.Groups["MyTermStoreGroup"];
$termSet = $termStoreGroup.TermSets["MyTermSet"];

Add-Type -Path ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Taxonomy.dll’
$taxonomyField = [Microsoft.SharePoint.Taxonomy.TaxonomyField] $myCustomList.Fields.CreateNewField(“TaxonomyFieldTypeMulti”, “Location”)
$taxonomyField.Required = $false
$taxonomyField.StaticName = “my_static_name”
$taxonomyField.SspId = $termStore.Id
$taxonomyField.TermSetId = $termSet.Id
$myCustomList.Fields.Add($taxonomyField)
$myCustomList.Update()
Write-Host “Added field ” $taxonomyField.Title ” to list ” $myCustomList.Title -ForegroundColor Green

$field = $myCustomList.Fields["Location"];
# PLEASE NOTE: It’s important to store the view in a variable, because calling list.DefaultView results in the creation of a NEW view object every time,
# if you do that, new columns will NEVER be added succesfully to the view.
$view = $myCustomList.DefaultView
$view.ViewFields.Add($field)
$view.Update()
$myCustomList.Update()

Write-Host “Added field ” $field.Title ” to default view” -ForegroundColor Green

Write-Host “Finished set metadata”

SharePoint 2010 Best Practices

It’s all about 2013 these days, nevertheless, whenever we see a reason, we’re updating the SharePoint 2010 Best Practices page as well. The Upgrade and Migration section has been updated at http://social.technet.microsoft.com/wiki/contents/articles/8666.sharepoint-2010-best-practices.aspx

Setting default content type column values for a library via PowerShell

Setting default column values for content type columns, the equivalent of [Document Library] > Document Library Settings > Column Default value settings, was surprisingly hard to build in PowerShell. The main gotcha has to do with the fact that you can’t do this via the SPContentType type, instead, you have to do it via the more obscure MetadataDefaults type, located in the Microsoft.Office.DocumentManagement.dll. Here’s the script:

Cls
Write-Host “Initializing SharePoint PowerShell Environment”

$SnapIn = “Microsoft.SharePoint.PowerShell”
if ( get-pssnapin $SnapIn -ea “silentlycontinue”)
{
  Write-Host “Remove SharePoint snap-in” 
  remove-pssnapin $SnapIn
}
if ( get-pssnapin $SnapIn -registered -ea “silentlycontinue”)
{
  Write-Host “Add SharePoint snap-in” 
  add-pssnapin $SnapIn
}

Write-Host “Start Setting default value for content type column”

Add-Type -Path ‘c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.DocumentManagement.dll’
$ProjectWeb = Get-SPWeb -Identity “http://demosrv/sites/Wilmie”
$List = $ProjectWeb.Lists["1. Project Management"]

$ContentType = $List.ContentTypes["TestContentType"]

$ColumnDefaults = New-Object -TypeName Microsoft.Office.DocumentManagement.MetadataDefaults $List                 
$ColumnDefaults.SetFieldDefault($List.RootFolder, “TestColumn”, “TestValue from PS”)
$ColumnDefaults.Update()

Write-Host “End setting default value”

PowerShell/SharePoint Error

We got the error New-SPSite : Could not find file ‘C:\Users\Administrator\AppData\Local\Temp\1\k5hcoe1g.dll when running a PowerShell script that created a SharePoint site collection. In the end, it turned out the code was fine, we just had to close the PowerShell window and open it again. Weird error message, huh?

Removing Ugly GUIDs from Database Names

Great resource about SharePoint Databases

SharePoint DR

Follow

Get every new post delivered to your Inbox.

Join 255 other followers