Skip to main content

Blogging about SharePoint

Search BlumenthalIT.Net:  
Home
Blogging about SharePoint
Public Speaking
  

Michael Blumenthal's BlumenthalIT.NET > Blogging about SharePoint
This is the blog where I discuss tips and tricks and lessons learned in my work with SharePoint.
Midwest GiveCamp needs Volunteers

A Message from Clark Sell, one of the organizers of Midwest GiveCamp:

Midwest Givecamp

Chicago’s very first GiveCamp kicks off July 9th – 11th at the Microsoft offices in Downers Grove, IL.

What is GiveCamp you ask?

GiveCamp is a weekend-long event where technology professionals from designers, developers and database administrators to marketers and web strategists, donate their time to provide solutions for non-profit organizations. Since its inception in 2007, the GiveCamp program has provided benefits to over 150 charities, with a value of developer and designer time exceeding $100,000 in services!

Midwest GiveCamp will be serving the following charities:

· Bear Necessities

· Sit Stay Read

· Porchlight

· Dreams for Kids

· The Caregivers Connection

· Bridges to Digital Excellence

My ask of each of you.

We are still looking for volunteers, if you or someone you know is interested please forward this along.  Our registration can be found here: http://bit.ly/af9Vrj

If you would like to become a sponsor please contact me directly.

Thank You,

Clark Sell

Midwest SharePoint 2010 Conference Sessions now available on CD!

If you missed the Midwest SharePoint 2010 Conference in Milwaukee, WI this spring (April 15th, 2010 to be exact), you can now get recordings of all the sessions on DVD.  My presentation was about best practices for building a corporate intranet on SharePoint 2010.  Here’s the link:

http://www.imergeportal.com/midwest_SP2010_cd_sessions.htm?src=michaelbl

Use coupon code SP59WI to get this $99 DVD for $59.

Michael

Checking the Ghosted / Customization State of a Master Page

The best practice is to deploy a site branding through a web solution package.  We had a third party do a branding for us, then needed to update it before they delivered the source code for the WSP to us.  So I found myself needing to update a master page for multiple site collections.  The master page was deployed via the WSP. If I updated it by uploading a new version of the master page to the Master Page Gallery in each site collection, I’d have to do that upload 20 times since we had 20 site collections.  But if I updated the file in its Feature folder in the 12 Hive, I’d only have to do the update once, and it would take effect everywhere assuming that the master pages that were out there were not customized from the site definition.  Could I use PowerShell to quickly report on the customization state of all instances of my master page? Of course!

function global:Get-SPWebApplication{
  Get-SPFarm |% {$_.Services} | where {'$_.TYPEName -eq "Windows SharePoint Services Web Application"'} |% {$_.WebApplications} |% {Write-Output $_}
}

function global:get-AllSiteCols($webAppName){
$WA = Get-SPWebApplication |where {$_.Name -eq $webAppName}
return $WA.Sites
}

function global:report-masterPageStates($masterFilename)
{

#example of $masterFilename: “mycustom.master’
$sites = get-AllSiteCols $webAppName
$sites | foreach {
    $site = $_
    $rootweb = $site.Rootweb
    $MPG = $rootweb.Lists["Master Page Gallery"]
    $masterItem = $MPG.Items | where {$_.Name -eq $masterFilename}
    if ($masteritem.File.CustomizedPageStatus -eq "Customized") {$fontcolor = "Red"} else {$fontcolor = "Green"}
    Write-host -foreground $fontcolor $site.Url":"$masterItem.Name ": Customization Status:" $masteritem.File.CustomizedPageStatus
    $rootweb.Dispose()
    $site.Dispose()
    }
}

--Michael

Creating Initial SharePoint Site Hierarchies with PowerShell – Part 1

At my current client, we are setting up a MOSS 2007 web application that provides collaboration sites for their communities of practice.  We have an initial site hierarchy of 155 sites across 20 site collections.  How do you set that all up?  Although we set up the 20 site collections manually (most got their own content databases, but that’s not the reason we did them manually. With only 20 items, in the time it would have taken to set up a script, it could also just be done, and it was good training for a new SharePoint support person.

For the sites however, we wanted to have each site based on the Publishing site template, have a set of preconfigured lists, use a branding feature we had installed, and have a welcome page that used a particular layout and had a particular set of web parts.  Because it was a publishing site, we couldn’t save it as a template.  However, we could save lists as templates, so that’s what we did.

  1. Save a list as a template:

    $list.SaveAsTemplate($filename, $templatename, $list.Description, $true); #true if you want to #include content, $false if you don’t.

  2. Once we have several templates saved in the List Template Gallery, we need to download them and then upload them into the other site collections.  So let’s download all templates to a local folder:

    function global:download-allListTemplates($dir,$siteCollectionURL)
    {
    cd $dir
    $site = get-SPSite $siteCollectionURL
    $rootweb = $site.RootWeb
    $LTG = $rootweb.Lists["List Template Gallery"]
    $LTG.Items | foreach {
        $_.Name
        $bytes = $_.File.OpenBinary()
        $bytes | set-content $_.Name -Encoding byte
        }
    $rootweb.Dispose()
    $site.Dispose()
    dir $dir
    }

  3. Now we can upload templates to the list template gallery.  The reason I do a .Replace(space, no-space) on the filename of the list stemplate is to remove any spaces from the filenames.  Also I am assuming that $templateLocalDir only contains list templates (.stp in MOSS 2007)
    1. function global:upload-listTemplatesTo($SiteColl,$templateLocalDir)
      {
      $rootweb = $siteColl.RootWeb
      $LTGrootFolder = $rootweb.GetFolder("List Template Gallery")
      Get-ChildItem $templateLocalDir | foreach {

          $stream = [IO.File]::OpenRead($_.FullName)
          if ($SiteColl.ServerRelativeUrl -eq "/"){
              $desturl = "/_catalogs/lt/"+$_.Name.Replace(" ","")
              }
              else {
              $desturl = $SiteColl.ServerRelativeUrl+"/_catalogs/lt/"+$_.Name.Replace(" ","")
              }
          Write-host Loading $_.Fullname to $desturl
          $resultingfile = $LTGrootFolder.files.Add($desturl,$stream,$true)
          $stream.close()
          Write-Host $_.Name uploaded to $resultingfile.Url in $siteColl.Url
          }

      $rootweb.Dispose()

      }

    You can loop over the set of site collections in your web app and do this for all of them.  To check your work, you can report on how many templates are in the List Template Gallery in each site collection.

    function global:get-AllSiteCols($webAppName){
    $WA = get-spwebApplication |where {$_.Name -eq $webAppName}
    return $WA.Sites
    }

    function global:report-TemplateCounts($webAppName){
    get-AllSiteCols $webAppName | foreach {
        $rootweb = $_.RootWeb
        $ltg = $rootWeb.Lists["List Template Gallery"]
        write-host $rootweb.Url $ltg.ItemCount
        $rootweb.Dispose()
        }
    }

    Once the templates are in the list template gallery, then you can create lists from all of them at once like this:

    function global:Create-AllCustomLists($web){
    $site = $web.Site
    write-host In $web.Url
    $templates = $site.GetCustomListTemplates($web)
    Create-FromTemplates $web $templates
    $site.Dispose()
    }

    function global:Create-FromTemplates($web,$templates){
    $templates |foreach {
            write-host Instantiating $_.Name
            if ($web.Lists[$listname] -eq $null) {
                $guid = $web.Lists.Add($listname, $_.Description, $_)
                $resultingList = $web.Lists.GetList($guid,$false)
                $resultingList.OnQuickLaunch = $True
                $resultingList.Update();
            } else {
                    Write-Host $listname "already exists."
                }
            }
    }

    Now you can create preconfigured lists in a site very quickly.  List templates won’t preserve the relationship to site columns though.  Lists that were created from templates will have list level column definitions for the columns that were originally site columns, and site column updates won’t roll down to these lists.

    Next time – more or less – I will cover setting up a welcome page based on a custom layout and adding web parts to pages, all via POSH.

    --Michael

    More of my posts about using PowerShell with SharePoint

    More PowerShell Scripting for SharePoint

    I realize I’ve been woefully behind in my blogging about the SharePoint work I’ve done with PowerShell.  Last year, I was working on a MOSS 2007 intranet website for a political action committee.  At a high level, here are some of the things I did.

    1. Use the choices in a choice field as the basis for a loop. $fieldname is the name of a column that is a Choices column.
      1. $choicefield = $list.Fields[$fieldname]
        $choicefield.Choices | foreach {

        #do something

        }

    2. Hide a navigation node (in a site with the Publishing feature turned on.
    3. $pages = $web.Lists["Pages"]
      #the following performs fine because the Pages list is small, actually VERY short, just 4 #items.
      $pages.Items |where {$_.Title -eq $publishingPageTitle} |foreach {
      $pageitem = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($_);
      $pageItem.IncludeInCurrentNavigation = $false}

      #Note that you may have to call $pageitem.Update() as well as checkin and/or publish #the item.

    4. Create a site template from a non-publishing site
      1. Actually, in this case, it was a publishing site where I used one  POSH script to deactivate the publishing feature and save the site (SPWeb) as  a template.  I then had another POSH script that created a new site (SPWeb) from the template, activated the Publishing feature, and fixing the navigation things that had gotten lost when the publishing feature was deactivated.  This let me use templates even though the site was a publishing site.
    5. Create a site from a site template
      1. $site.AllWebs.Add($name,$name,"",1033,"mycustom.stp",$false,$false)
        1. Note that in this case, site name and relative URL are the same
    6. Create a bunch of data. Creating list items from spreadsheets is really easy.  Import-csv is a very helpful cmdlet!
    7. Create folder list items as well as regular list items. In this case, I am creating the folders in the root of the list.
      1. $FolderConst = 1

        $folder = $list.Items.Add($list.RootFolder.ServerRelativeUrl,$folderConst)
        $folder["Title"]=$foldername
        $folder.Update()

    One of the advantages of POSH is that it lets you – without the overhead of building a compiled app – use Data Form Web Parts (DFWP) in more ways. For example, you can use POSH to use the SharePoint API to update the properties of the DFWP, including changing list IDs or filter expressions.  I had a web part

    For my next blog post, I will (hopefully) talk about all the POSH scripting I have been doing for my current client, a Fortune 500 engineering firm, to create 155 sites across 20 site collections in a MOSS 2007 web application.

    CSPUG Hosts, Magenic Sponsors SP2010 Community Launch Party, May 12, Downers Grove and Chicago

    Join other Chicago area SharePoint professionals in Chicago or Downers Grove as we watch Stephen Elop, President of the Microsoft Business Division, announce the launch of Office 2010 and SharePoint 2010.

    Register at www.cspug.org!

    --Michael

    Slides from my presentation to QCSPUG – Overview of SP2010

    Last week, May 22nd, I had the great honor of speaking at the first meeting of the Quad Cities SharePoint User Group.  I presented an overview of SharePoint 2010.  My slides are here:

    SharePoint 2010 Overview for QCSPUG by Michael Blumenthal of Magenic

    Also note that that my new whitepaper is now available here: CIO’s Guide to Corporate Intranet Success (registration required).

    --Michael

    Slides from Midwest SP2010 Conference

    I just posted them here: Ten Essentials for SharePoint Intranet Success - Magenic - Blumenthal - Midwest SP2010 Conf

    The slide deck includes a few slides that I didn’t have time to present (think of that as bonus content).

    For those of you that missed the conference, the sessions are available for purchase on CD here: http://www.imergeportal.com/midwest_SP2010_cd_order.htm

    --Michael

    SharePoint 2010 RTM’d!

    Again, Twitter is a great way to stay up on the latest in the SharePoint world.

    Read about it here: http://blogs.msdn.com/sharepoint/archive/2010/04/16/sharepoint-2010-reaches-rtm.aspx

    For those of you who attended my session on 10 Essentials for SharePoint Intranet Success yesterday, I will post my slides this weekend.

    Michael

    Upcoming Community Events; SPUG Resources; Blog Note

    Upcoming Community Events

    Next month there are two regional community events that I think you should know about:

    1. The Midwest SharePoint 2010 Conference.  April 15, 2010. Milwaukee, WI. http://www.imergeportal.com/midwest_SP2010_Conference.htm
    2. The Quad Cities SharePoint User Group. April 22,  Davenport, IA. http://qctrainingsolutions.com/QCSUG.html

    I will be speaking at both of them.

    The Quad Cities SharePoint User Group is new, and I am very honored to be its first speaker. I will be providing an overview of SharePoint 2010.

    For the Midwest SharePoint 2010 conference I will be talking about SharePoint best practices.

    Of course, we have upcoming CSPUG meetings which are listed on www.cspug.org .

    SharePoint User Group Resources

    For SPUG leaders, are you aware of the following resources?

    Blog Note

    If you have been kind enough to leave a comment on my blog, and it’s not been approved, I’m sorry. I am drowning in blog comment spam, and until I can implement some form of CAPTCHA, I just don’t have time to sort through all the garbage to find your comments.  If you have a comment that needs approval or want to contact me,  contact me via email or LinkedIn.

    1 - 10 Next

     Recommended Books

    Recommended SharePoint Books
     
    SharePoint Connections

     ‭(Hidden)‬ Admin Links