Friday, October 29, 2010

Handy powershell script for "Data is Null" error

Earlier I blogged about a "Data is Null" error breaking the search in SharePoint 2010.

Seems that while we were on the right path, the cause of the problem was just a little off.  When creating a new site group through code, the parameter that was causing the problem is not the "default user" parameter but rather the "description" parameter. When the description is null, the search breaks.

Microsoft has a fix ( on their website for updating the null description values and while the fix is perfectly valid, it is code and you may not be allowed to run this code in all cases. (Try getting approval to run a console app on a production machine).  So here is a small powershell script to help you fix the NULL descriptions.

Function UpdateEmptyDescriptions($siteUrl)
        $site =  Get-SPSite $siteUrl
        $needupdate = $site.RootWeb.SiteGroups  | Where-Object {$_.Description -eq $NULL} 
            Write-Host "Site Groups that are being updated"
            Write-Output $needupdate | Format-Table Name
            $needupdate | ForEach-Object{$_.Description = $_.Name}
            $site.RootWeb.SiteGroups | % {$_.Update()}
            Write-Host "No Update Needed"


A moment of clarity

Today I had a moment of clarity when typing the name of a SharePoint assembly. I was getting Powershell ready to use with SharePoint and typed:

Add-PSSnapin Microsoft.SharePoint.PowersHell

Something caused me to hit the shift key at just the right moment, and I realized how wide SharePoint adoption is.   :)

Friday, October 15, 2010

Article on LINQ to SharePoint

I recently had an article published in the DIWUG SharePoint eMagazine, introducing LINQ to SharePoint. The magazine is a free download and has some great content so get yourself a copy at