SharePoint 2010 SP1 is out, but wait there’s more!

So SharePoint 2010 Service Pack 1 is available for Download.

The SharePoint team are also shipping a June 2011 CU with a bunch of fixes that didn’t get into SP1 and it’s “ strongly recommended to install the June 2011 Cumulative Update immediately after the installation of Service Pack 1.”

More detail over on the SharePoint blog: http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?pID=984

Also included are a few FAQs.

So, what’s in SP1?: Check out Andrew Connell’s post about What’s New In Service Pack 1, this of course is additional to all the hot fixes and previous CUs that are bundled into the service pack.

Posted in Maintenance, Service Pack, SharePoint, SP1 | Leave a comment

Running SharePoint Timer Jobs from PowerShell

From time to time you need to execute a given SharePoint timer job now. Sure you could go into Central Admin, find it and run it manually, but where’s the fun in that? Plus sometimes you need to automate this, say in an install scenario.

Luckily it’s dead easy using the SharePoint cmdlets

Heck you can do it in a couple of lines with some pipelining.

$WebApp = Get-SPWebApplication http://mywebappurl
$job = Get-SPTimerJob | ?{$_.Name -match $JobName} | ?{$_.Parent -eq $WebApp}

Or if you’d like to be a bit more robust and re-usable:

function StartJobOnWebApp
{
	param([Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)]
    [Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]
    $WebApplication,
	[Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=1)]
	[string] $JobName)
	process
	{
		$WebApp = $WebApplication.Read() 
		$job = Get-SPTimerJob | ?{$_.Name -match $JobName} | ?{$_.Parent -eq $WebApp} 
		if($null -ne $job)
		{
			Write-Host -ForegroundColor Yellow "Starting "$job.DisplayName
			Start-SPTimerJob $job
		}
	}
}

Posted in PowerShell, SharePoint, Timer Jobs | 2 Comments

Browser Caps for WP7 as a Mobile Device

So, people are using the Windows Phone 7 browser now, I’m one of them; I love my WP7. Anyway OOTB SharePoint doesn’t recognise the this as a mobile browser. So I had to edit the compat.browser file ( %WebAppRootDir%\ App_Browsers\compat.browser ) to make SharePoint recognise this browser as a mobile one.

After I had a few trial and error attempts I thought that you all might like to see what a valid setting for this looks like:

<!-- Case: Windows Phone 7 phone using MSIE-->
<!-- User Agent: IE Mobile -->
<browser id="WP7" parentID="IE6to9">
	<identification>
		<userAgent match="Windows" />
		<userAgent match="Phone" />
		<userAgent match="OS" />
		<userAgent match="7.0" />
	</identification>
	<capabilities>
		<capability name="isMobileDevice" value="true" />
	</capabilities>
</browser>

Posted in Deployment, SharePoint | Leave a comment

Disable Mobile Redirection for a Web Application via PowerShell

So I’ve got a SharePoint site that is optimised for viewing in mobile browsers, problem is that OOTB SharePoint is trying to show the fugly “mobile view”. Now Waldek has a post about just this problem, in my case I’ve decided that his first offered work around is perfectly acceptable for my scenario.

Now if you haven’t worked it out yet I also have a requirement that my deployments must be 100% repeatable and driven my PowerShell. So I need to modify the web.config file via PowerShell, enter a helpful post from the Script Guy blogs.

From there it wasn’t too hard to create my own script:

#Disable Mobile Redirection for all browsers for a given web application

param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0)] 
			[Microsoft.SharePoint.PowerShell.SPWebApplicationPipeBind]
			$WebApplication)
	
# SharePoint cmdlets
Add-PSSnapin Microsoft.SharePoint.PowerShell
if([Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")-eq$null){throw "Unable to load Microsoft.SharePoint.dll";}

$WebApp = $WebApplication.Read()

$configMod1 = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$configMod1.Path = "configuration/system.web"
$configMod1.Name = "browserCapsModification"
$configMod1.Value = '<browserCaps><result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /><filter>isMobileDevice=false</filter></browserCaps>'
$configMod1.Sequence = 0
$configMod1.Owner = "contoso\administrator"
## SPWebConfigModificationType.EnsureChildNode -> 0
$configMod1.Type = 0

$WebApp.WebConfigModifications.Add( $configMod1 )

$WebApp.Update()

$WebApp.Parent.ApplyWebConfigModifications() 
	
Remove-PsSnapin Microsoft.SharePoint.PowerShell
	

I highly recommend that you read both the blogs I linked above, it’s articles like those that enable me to stand on the shoulders of giants to achieve my ends

Posted in Deployment, Development, PowerShell, SharePoint | 4 Comments

Provisioning Web Parts via the AllUsersWebParts element

Right, so you want to have a Page Layout that contains some web parts when a user creates a page using that layout. Cool, no problem, use an <AllUsersWebParts> element just like Andrew Connell blogs about problem is, if you activate that feature multiple time you’ll get an instance of the web parts in the provisioned page for each activation.

Now, Waldek suggests some approaches to use for provisioning web part instances and the one that fits is going to depend on your needs.

But what happens if you’ve gone down the AllUsersWebParts path and are now running into problems, as I was today? Well, with a quick bit of coding I whipped up a command line tool to remove all the web parts form a page layout. If you do this then re-activate the feature that provisions the page layouts (and their web parts) you will get back to a state of one instance of each desired web part.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.WebPartPages;
using WebPart = System.Web.UI.WebControls.WebParts.WebPart;

namespace RemoveWebPartsFromPageLayout
{
    class Program
    {
        static void Main(string[] args)
        {
            if(2 != args.Length)
            {
                Console.WriteLine("usage: RemoveWebPartsFromPageLayout <SPSiteUrl> <PageLayoutTitle>");
                return;
            }
            using(SPSite site = new SPSite(args[0]) )
            {
                using (SPWeb web = site.RootWeb)
                {
                    if (PublishingWeb.IsPublishingWeb(web))
                    {
                        PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);
                        foreach (var layout in pubWeb.GetAvailablePageLayouts())
                        {
                            if (args[1] == layout.Title)
                            {
                                DeleteWebParts(layout);
                            }
                        }
                    }
                }
            }
        }

        private static void DeleteWebParts(PageLayout layout)
        {
            SPFile file = layout.ListItem.File;
            if (file.CheckOutType == SPFile.SPCheckOutType.None)
            {
                file.CheckOut();
            }
            using (SPLimitedWebPartManager wpm = file.GetLimitedWebPartManager(PersonalizationScope.Shared))
            {
                List<WebPart> deletes = (from object webPart in wpm.WebParts select webPart as WebPart).ToList();
                foreach (var webPart in deletes)
                {
                    wpm.DeleteWebPart(webPart);
                }
                file.CheckIn("WebParts Deleted");
                file.Publish("WebParts Deleted");
                file.Approve("WebParts Deleted");
            }
        }
    }
}

Posted in Development, SharePoint | Leave a comment

Boo-yah! @nzben to join Intergen

So, according to both Twitter and the NBR, Ben Gracewood, aka @nzben aka  that guy with the cool toys from Breakfast, is joining Intergen.

I’m pretty stoked that he’ll be joining the team here and hope to lean a lot while working with him.

-Gavin

Posted in General, Intergen, News | Leave a comment

Try out Azure and win*

So Microsoft New Zealand have set up a sweet competition, basically try out the Windows Azure platform and you’re in with a chance to win up to $1550 worth of Prezzy Cards. One $50 daily draw and then a $500 draw at the end.

You don’t even need to be a ‘Developer’ to enter, even the ‘Next, Next, Finish’ IT Pro crowd can handle this Winking smile (Kidding, I love the work done by IT Pros). Here’s what you need to do:

1. Visit http://be.1tri.be/

2. Setup your free (Credit Card Free too) 30 Day Windows Azure trial account.

3. Follow the instructional video (http://be.1tri.be/Begin) to upload the supplied Windows Azure Solution Package

Once you’ve done that the great thing is that you have a month of free access to the Azure platform to try it out and see what Microsoft are offering in the cloud computing space.

*Only people living in New Zealand are eligible to register for the Competition and enter the prize draws, full competition Terms and Conditions
Posted in Azure | Leave a comment