SharePoint Dragons

Nikander & Margriet on SharePoint

Monthly Archives: April 2013

Tip for uploading large files to SharePoint Online

Great discussion about uploading large files to SharePoint Online: http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/4b1ebe96-9c87-4a81-924a-5f7c7e789090

Advertisements

SharePoint 2013 Best Practices: Using Folders

Should you use folders or not?
Advantages

  • Scale by partitioning a document library
  • To apply permissions more effectively
  • To use location based default metadata properties. You can set default metadata values for every folder. In ‘Library settings’, ‘Column Default Value settings’, you can set defaults on all of you subfolder starting from the root(inherits by default). Also check out the Location-Based Metadata defaults feature: http://msdn.microsoft.com/en-us/library/ee557925.aspx  .
  • Folders are great for finding info when you know your way around the folder structure.
  • Folders improve the efficiency of data access because the creation of a folder leads to the creation of an internal index. 
  • Folders work great in scenarios where file shares are used. In a file share, the only way of classifying files is through filename and folder structure. In SharePoint we have a choice, and you could consider using both folders and metadata together.
  • Folders work a lot better with Windows explorer views. In a flat structure you see everything and nothing in one view….
  • Document sets inherit from the folder content type. So, even if you resent the idea of using folders, you’re probably still a fan of using them without recognizing it (that is, unless you deny the usefulness of Document Sets).
  • You can use folders while still removing them from view. If you don’t want to use the folders all the time, create a view that does not display the folders. In ‘Library settings’ – ‘Create View’ – ‘standard view’ – under ‘Folders’ – you have a choice of ‘show all items without folders’. This will turn your folder based structure into a flat library.
  • Folders is a great way to introduce metadata to old school change-reluctant users, using default folder values will allow you to add metadata without the user noticing.
  • Folders save you time in migrations if you can copy an existing fileshare folder structure.

Disadvantages

  • If you don’t know the folder structure, finding info is easier using metadata based navigation.
  • Folders increase URL length, which breaks when it pops above around 260 characters. See: http://www.loisandclark.eu/Pages/limitsurl.aspx
  • Folders don’t look great when you put a Library web part on a page (there’s no navigation back up to the parent folder).
  • Folders without metadata, can cause you to ‘loose’ documents.

Additional comments about Security…
You can have several document libraries in one site, that is also a way to separate security/permissions. There is a commercial third party tool available for SharePoint that allows you to set permissions by the use of metadata. So, if you’re interested in that, you can investigate further.

Best Practices
Try and keep the folder hierarchy as flat and minimal as you can, but don’t limit yourself to metadata views exclusively. Mix the opportunities for the best results!  If you choose to depend on metadata only, you should separate sets of documents by putting them in its own websites and set the permissions on this level. If you need a more granular rights management, folders/libraries are the easier way to do it.

See Also

For an up to date version of this discussion, bookmark the TechNet Wiki page at http://social.technet.microsoft.com/wiki/contents/articles/16166.sharepoint-2013-best-practices-using-folders.aspx

PowerGUI – This host does not support Start-Transcript

If you want to use the PowerShell dev friendly PowerGUI tool AND use Start-Transcript, download and install the Transcription add-on at http://powergui.org/entry.jspa?externalID=2910

Better Canadian Communication

Comment for Social Spark: Always stare at a spectacle (human readers: please ignore this sentence)

After World War II, many Dutch people decided there was no future anymore in a, at that time, destroyed country. Most of them emigrated to Canada, and tried to build a new life. Some of the members of our family did the same, and although we don’t nearly see them often enough, whenever we do it’s special. They started a small plush upholstery company which has existed for decades now. But, to our surprise, even a traditional company like this at some point evolves to a place where technology becomes a part of the work, things like multiple phone lines, high speed internet, email and a domain name for a web site. We looked into it, and it seems that AllStream (“Canada’s all-business communications provider”) at what is sip trunking can help them further. Maybe it can help you too!

Remember the Promise you made

Check out Margriet’s latest TechNet Wiki Blog Post at: http://blogs.technet.com/b/wikininjas/archive/2013/04/09/remember-the-promise-you-made.aspx Interestingly enough, the name of the group performing the song “The Promise You Made”, didn’t make it thru the censorship and is now called **** Robin. Oh, well.

SharePoint 2013 Version Number Overview

Here’s an overview of SharePoint 2013 versions.

  1. Beta 1 Preview 15.0.3612.1010
  2. Beta 1 refresh 15.0.3919.1011
  3. Beta 2 interim 15.0.4107.1000
  4. Beta 2 public preview 15.0.4128.1014
  5. Escrow / Release Candidate 15.0.4420.1006
  6. RTM 15.0.4420.1017

If you need to look it up, keep track of this list at http://social.technet.microsoft.com/wiki/contents/articles/12438.sharepoint-2013-best-practices.aspx#Development , where the list will also be updated.

Adding users and groups to SharePoint 2010 Lists via PowerShell Braindump

A braindump follows the train of thought of a person solving a problem. This process allows you to optimize through processes and reasoning patterns, and as such can be a useful and entertaining exercise. What follows is the braindump of adding users and groups to SharePoint 2010 Lists via PowerShell.

Let’s start by firing the SharePoint 2010 Management Shell and see what I can learn about SharePoint related PS commands.

I know that such commands contain “sp” in it, so I’ll do:

help *sp*.

Ah, that’s too much. I assume that I need to retrieve a list before I can add permissions, but in order to do that I’ll probably need to get hold of the correct site collection and site first. In that case, I’ll just go ahead and look for cmdlets that have get in it. I do:

help get-sp*

There they are, on the first page, Get-SPSite and Get-SPWeb. They look promising. Let’s see if I can get a site directly by using Get-SPWeb. But in order to do that, I first need to find out how to use it. I want to read the documentation, so I do:

help get-spweb -full

Hmm, if I take a look at the -Identity parameter, it seems to be enough to get hold of a specific site. Let’s try it.

get-spweb http://moon

Ok, got it. That wasn’t too bad. I notice that now i have an SPWeb object. Now, let’s see what I can do with a site, there should be a way to get a specific list. I do:

get-spweb http://moon | gm | more

Either the GetList or the GetListFromUrl method should help me to get a list. Let’s switch to MSDN at http://msdn.microsoft.com and look for:

spweb getlist

As it turns out, this method needs a server-relative URL for a list, for example, /sites/MySiteCollection/Lists/Announcements. That’s good enough for me. Once I have an SPList object, I’ll see what I can do with that. I’ll change the PS code a bit, so that I’ll have references to the various objects. I do:

$web = get-spweb http://moon
$list = $web.getlist(“/Lists/TheTestList”)

Let’s see that I really got it and try:

$list.Title

Fine, let’s find out about the list object then. I do:

$list | gm | more

Hmm, things are getting a little bit more complicated. Time to fire up Windows PowerShell ISE and work from there. That won’t do me any good unless I load the SharePoint PS snap in first. So, I do:

$snapIn = “Microsoft.SharePoint.PowerShell”

if ( get-pssnapin $snapIn -ea “silentlycontinue”)
{
  remove-pssnapin $snapIn
}

if ( get-pssnapin $snapIn -registered -ea “silentlycontinue”)
{
  add-pssnapin $snapIn
}

$web = get-spweb http://moon
$list = $web.getlist(“/Lists/TheTestList”)

The traditional PowerShell approach is getting too cumbersome by now. Instead of continuing going down this road, let’s find some C# code which does what I want and convert it to PowerShell.

$snapIn = “Microsoft.SharePoint.PowerShell”

Write-Host “Initializing SharePoint PowerShell Environment”
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 “Get web”
$web = get-spweb http://moon
Write-Host “Get list”
$list = $web.getlist(“/Lists/TheTestList”)

#Reset permissions
Write-Host “Reset to original security settings”
$list.BreakRoleInheritance($False)
$list.ResetRoleInheritance()
Write-Host “Break role inheritance”
$list.BreakRoleInheritance($True)

# Remove all current assignments.
Write-Host “Remove all Role assignments”
Write-Host “Count:” $list.RoleAssignments.Count
while ($list.RoleAssignments.Count -gt 0)
{
  Write-Host “Removing a specific assignment for” $list.RoleAssignments[0].Member.Name
  $list.RoleAssignments.Remove(0)
}
Write-Host “Count:” $list.RoleAssignments.Count

$userName = “lc\Administrator”
$user = $web.EnsureUser($userName)
Write-Host “user:” $user
$userRole = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
$builtInRole = $web.RoleDefinitions[“Read”]
Write-Host “Built in role” $builtInRole.Name

$userRole.RoleDefinitionBindings.Add($builtInRole)
$list.RoleAssignments.Add($userRole)

$groupName = “SharePoint Dragons Owners”
$group = $web.SiteGroups[$groupName]
Write-Host “Group:” $group
$groupRole = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
$groupRole.RoleDefinitionBindings.Add($builtInRole)
$list.RoleAssignments.Add($groupRole)

Write-Host “Finished”

Ah, there’s my proof of concept that I can later convert to Enterprise-level code. Now, let’s write that blog post.

Tool for checking WiFi networks around you

Lately, we had to use the Inssider tool to check WiFi networks around our home, the strength of their signals, and the channels that were being used. Quite a nice tool: http://www.metageek.net/products/inssider/

More SharePoint Feature Overviews

This page has a nice overview of SharePoint 2013, 2010, 2007, and Office 365 overviews: http://www.rharbridge.com/www.rharbridge.com/?page_id=966 The definitive collection of valuable SharePoint 2013 feature overviews can be found at http://social.technet.microsoft.com/wiki/contents/articles/12438.sharepoint-2013-best-practices.aspx#Feature_Overview

Appreciating a simple idea about running PowerShell Scripts from SharePoint

It’s a simple idea to want to be able to execute PowerShell scripts from code, as you can see in http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/318429d9-fc63-479b-a20a-62883c9132fa. The code is something similar to this:

PowerShell ps = PowerShell.Create();

string scriptText = “Add-PSSnapin Microsoft.SharePoint.Powershell Enable-SPFeature -Identity PublishingSite -URL ” + siteAddress + ” -Force”;

Runspace runspace = RunspaceFactory.CreateRunspace();

runspace.Open();

Pipeline pipeline = runspace.CreatePipeline();

pipeline.Commands.AddScript(scriptText);

pipeline.Commands.Add(“Out-String”);

Collection<PSObject> results = pipeline.Invoke();

runspace.Close();

StringBuilder stringBuilder = new StringBuilder();

foreach (PSObject obj in results)

{

stringBuilder.AppendLine(obj.ToString());

}

return stringBuilder.ToString();

}

In the blog post http://blog.karstein-consulting.com/2011/08/04/sharepoint-powershell-timer-jobs-run-powershell-scripts-in-sharepoint-timer-service-context/ this idea is taken to the next level by allowing you to run PowerShell scripts in the SharePoint Timer Service context. Really useful, and elegantly done!