The SharePoint Coffee House
I'd like some SharePoint with my coffee please...

Migration Issue: "One or more field types are not installed properly"

Friday, 5 August 2011 18:26 by Michael Mukalian

This was one that was wracking my brain, and then I came across a post that explains the issue and proposes a resolution.

In a nutshell, there's a hidden list at the top-level site of a site collection named Relationships List.  This list is an internal list that stores all of the metadata involved in the creation of Variations.  Apparently during the migration (in this case I was doing a Content DB migration/upgrade) this list wound up not migrating correctly, and it didn't have the necessary GroupGuid column.  The article says that you can download a tool from codeplex to perform the migration of this list, however, given where I was doing this work, external tools weren't an option.  So...

Enter PowerShell!

(I'm really liking PowerShell more and more...granted I'm a devhead at heart, but you're able to quickly address issues that occur in your implementation in a quick manner, with repeatable solutions)

So...how to do this?  Well, deleting/migrating the list wasn't really an option, and given that the field type of the column isn't available through the UI (it's a GUID, as well as being a hidden column), I turned to PowerShell to create it.  So...let's take a look...

Basically, I took a look at the list in a working site collection and grabbed its properties, and used it to create a working script to add the missing field to the site collection with the issues.  It's relatively smiple...grab your web, grab your list, create the field, add it, modify some properties, and you're good to go.  Running the script enabled the site collection that had the above error work right away.  So, take a peek at the below, and enjoy. - M

# load up SP PS Snappin            
Add-PSSnapin Microsoft.SharePoint.Powershell            
# get web            
$web = Get-SPWeb -Identity http://websiteUrl            
# get list            
# note that the code below isn't optimized            
# but just to get the list quick 'n' dirty            
$list = $web.Lists["Relationships List"]            
# create Guid SPFieldType field            
$guidField = [Microsoft.SharePoint.SPFieldType]::Guid            
# add the created field to the list, the name 'GroupGuid' is necessary            
# and it's required            
$list.Fields.Add("GroupGuid", $guidField, $true)            
# once added, let's grab it as a SPField            
$groupGuidField = $list.Fields.GetField("GroupGuid")            
# set its ShowInEditForm property to False            
$groupGuidField.ShowInEditForm = $false            
# add an index on this field            
$list.FieldIndexes.Add($groupGuidField)            
# cleanup            
$web.Dispose()            
# remove SP PS Snappin            
Remove-PSSnapin Microsoft.SharePoint.Powershell

Currently rated 3.6 by 7 people

  • Currently 3.571428/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   2010 | Migration | PowerShell
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

PowerShell Script to Delete All Versions in a Document Library

Sunday, 10 April 2011 21:41 by Michael Mukalian

The question was asked of how to delete all versions of a document in libraries in a site collection.  So, I wound up whipping up this script kinda quick.  It's nothing too crazy, but what I've been trying to do of late is to see how often I can write the script so that it'd work in both SharePoint 2007 and 2010.  Granted I do this cause I've been worknig on both versions of late, but I can see more and more leaning more towards the SharePoint 2010 cmdlets as 2010 is adopted more.  So, that being said...

What we have below is a script that instantiates a site collection, loops through all its webs, identifies the document libraries only, goes through each item, and deletes all of the versions of the item, leaving only the current version.  It's good to note here that since this is a document library we're dealing with you need to work with the SPFile object.  That's pretty much it, nothing crazy and it's not rocket science, right?  Again, as before, keep in mind that the disposal of the web and site objects are a necessity.

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
# get site
$site = new-object Microsoft.SharePoint.SPSite("http://mossdev:8000")
# loop through webs
foreach ($web in $site.AllWebs)
{
  # loop through all lists in web
  foreach ($list in $web.Lists)
  {
    # examine if BaseType of list is NOT a Document Library
    if ($list.BaseType -ne "DocumentLibrary") 
    {
      # forget the rest and return to top
      continue
    }
    # loop through each item
    foreach ($item in $list.Items)
    {
      # work with the file object as we're in a document library
      $file = $item.File
      # delete all versions
      $file.Versions.DeleteAll()
    }
  }
}
$web.Dispose();
$site.Dispose();

Note: Take a look at Gary Lapointe's blog for all things (and I mean all) PowerShell.  Awesome reference out there.

Enjoy! - M

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   2010 | PowerShell | 2007
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

PowerShell Script to Change Navigation Inheritance

Friday, 1 April 2011 18:13 by Michael Mukalian

The question was asked of how to change the inheritance of subsites under a site collection via PowerShell, as there could be a ton of sites under the root.  Turns out, it's not too hard.  Check out the script below.  This sets all the subsites to inherit...

# get the site collection
$spSite = Get-SPSite -Identity "http://sitecollection"
# loop through all the webs in the site collection
foreach ($spWeb in $spSite.AllWebs)
{
	# check if root web as this one doesn't obviously inherit
	if (!$spWeb.IsRootWeb)
{
		# grab a Navigation object
		$spWebNavigation = $spWeb.Navigation
		# change to true
		$spWebNavigation.UseShared = $true
}
	# cleanup
	$spWeb.Dispose()
}
# cleanup
$spSite.Dispose()

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   2010 | PowerShell
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed