SharePoint Dragons

Nikander & Margriet on SharePoint

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!

Web Essentials

Web Essentials is a really handy tool that adds features to Visual Studio that make working with CSS easier. The coolest feature is that it’s able to generate CSS for other browsers/platforms automatically. Get it here: http://visualstudiogallery.msdn.microsoft.com/6ed4c78f-a23e-49ad-b5fd-369af0c2107f

Fishbone: Waiting for CKSDev

We’re writing this in advance, so it’s possible that a version of CKSDev for the combi of VS.NET 2012/SharePoint 2013 has been released, but in the mean time, check out the Fishbone Systems VS.NET 2012 extension at http://visualstudiogallery.msdn.microsoft.com/4784e790-32f4-455f-9228-53f537c03787 : it allows you to copy to the SharePoint root, perform an iisreset, reset the SharePoint Timer Service, and copy DLLs to the GAC. Maybe not as cool as CKSDev, but still very useful!

More PowerGUI

If you read our previous post about the separate PowerGUI tool, you may also be interested in the Visual Studio extension that adds PowerShell IntelliSense support to Visual Studio. Not too shabby, eh? Find it at http://powerguivsx.codeplex.com/