How to change the Content Type Hub URL in Managed Metadata Service

When you create a Content Type Hub site, you need to specifiy the URL in the Managed Metadata Service. Once you entered the URL, there is no GUI way available to change that URL. Good thing for us that PowerShell does have a way!

Set-SPMetadataServiceApplication -Identity "service application name" -HubURI "content type hub url"​

Upload button in Document Center not working?

I recently created a Document Center in SharePoint 2010. Just the out of the box template, with the nifty upload Document button.

After some swapping around with webparts, I noticed the upload button stopped working. I click it, and nothing happens. Why you ask? Well, I do not know, yet. But, I do know how to fix it! ​

I compared the script behind the ‘broken’ upload button with the original script and found that there was some code missing in the <button> element.

original:

<button onclick="javascript:OpenNewFormUrl('Documents/Forms/upload.aspx');return false;">
    <nobr><img alt="Upload a Document" src="/_layouts/Images/uploaddoc.png"></img>&nbsp;<span>Upload a Document</span></nobr>
</button>               ​

broken:

<button>
<nobr><img alt="Upload a Document" src="/_layouts/Images/uploaddoc.png"/>&#160;<span>Upload a Document</span></nobr>
</button>

Weird, but it can be repaired! Open the Document Center with the broken upload button in SharePoint Designer. Find the code for the upload button and add the red line of code in the <button> element.

Save, and the upload button is back in business!

Hello world, in C!

First program of the week!​ Well, program, it’s hello world, but hey, I’ve got to start somewhere!


#include
int main () {
printf("Hello world!\n");
return 0;
}

Learning C is like climbing Mount Everest

For over a year now, I’m in a struggle to master the C programming language. It is hard. Got myself a few online tutorials:

Getting started with C

How to start coding in C

Cocoa Dev Central: learning C on a Mac

And I’m plowing my way through Learn C on a Mac from Dave Mark. But even with those good resources, I’m finding myself searching for good a IDE on the Mac, looking for better tutorials or google’in for people who are learning C, instead of just learning C myself!

The trick in learning a programming language is: do it. just code, type the code, understand to code and solve problems with the code. So why don’t I do just that?

Well, I’m scared of the code. I don’t know enough about it. There is so much to learn, it’s like standing on the foot of Mount Everest looking up to the top, knowing that is where you want to go. But it’s a long and cold climb. And I’m afraid to take that climb.

That’s got to go. I’m going to take this climb step by step. Starting now, by writing a small piece of code every day. It doesn’t have to be a full blown program. Just a function, method or something I just learned.

I know C is not the easiest programming language to learn. From others I hear Python​ or Javascript​ is much easier to start with. But, C is the mother of almost all programming languages. It feels right to start here.

I’ll tell more about my programming set-up on the Mac when I wrote my first piece of code here ;-)

Create an Omnigraffle filetype association with icon in SharePoint 2010

I’m a Apple user. My Apple MacBook Pro 17″ is “my precious”. Because of this love, I’m forced to use alternatives for common Microsoft products, like Visio. That’s no problem, because there are a lot of good Mac programs with the same functionality. My personal choice is Omnigraffle created by the OmniGroup, a great Visio alternative. Of course integration with SharePoint is non-existent. But that’s something we can partially fix. Check in and out functionality in the Omnigraffle application is a bridge to far, but I can make SharePoint recognize the .graffle filetype and associate an icon with it.

First, we need an 16×16 pixel icon. I googled my way to a nice icon and copied the .png file to the SharePoint 14 Hive: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\

When ready, launch your favorite text editor and open the DOCICON.XML file from that same 14 Hive, but this time the XML directory : C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\

Create a mapping like this:and save the DOCICON.XML file.

Next, open the Central Administration – Manage service applications and open your Search application

In the Search application, choose File Types

Create a new File Type with the name graffle. Now .graffle files are picked up by the Search, so you can find them! After you create the File Type, the .graffle extension should be visible in the File Type list with the appropriate icon.

Last steps are an IISRESET and a full crawl of your index, and there it is: your .graffle documents have a nice icon and show up in the search results!

This procedure can be repeated for all not yet recognized filetypes in SharePoint. Next step is figuring out how I can make SharePoint open Omnigraffle to edit the .graffle file, instead of downloading the file!

Create a backup schedule for a SharePoint 2010 farm with PowerShell

SharePoint 2007 did not have a great backup tool onboard. The backup was slow, unreliable and worst of all, not really configurable. SharePoint 2010 does a better job at backups. Ok, I still miss the possibility to create a schedule in the Central Administration, but I can make different kinds of backups and the restore procedure is flexible.

The Central Administration way to backup is easy. Just follow the steps in the wizard, and the backup starts. But what if I want to schedule, say a farm backup, every week? PowerShell and the Windows Server Taskscheduler will make it happen!

To create a backup on farm level, we have to write a PowerShell script, with the following lines:

add-PSSnapin Microsoft.Sharepoint.Powershell

Backup-SPFarm -directory [location\backup.file] -backupmethod full

Save this script as SPbackup-full.ps1 somewhere on your server. Next step is the Taskscheduler. Create a new basic task, choose the schedule and on choose the “Start a program” option. On the next screen type PowerShell.exe as program to start, and locate the SPbackup-full.ps1 script on your harddrive.

Choose next, and check the advanced properties box on the bottom of the summary dialogbox. In the properties dialogbox pick the SharePoint Farm administrator account, and check Run whether user is logged on or not ​and Run with the highest privileges.

Ok, and your backup is scheduled. In the task summary pane, rightmouse click the backup task and choose run. Now the backup job is in line at you SharePoint farm, waiting to be executed. You can check the status of the backup in the Central Administration – Backup and Restore - View backup and restore history.

Creating a backup on Farm level is nice, but it could be very handy to have a backup on site collection level. No problem, just use the following PowerShell commands to backup and restore a site collection. This backup gets all you content and customisations, but it won’t backup your site specific solutions! You need a full Farm backup to get the solutions in the backup.

Create backup on site collection level

Backup-SPSite [sitecollection] -Path [location\backup.file]

Restore backup om sitecollection level

Restore-SPSite -Path [location\backup.file]