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"



Unknown said...
This comment has been removed by the author.
Unknown said...

I have developping a little Windows Form to do the job.