Monthly Archives: October 2012

Updating SharePoint Absolute URLs With Relative URLs Using Windows PowerShell

One of many common concerns during SharePoint upgrades are hard-coded or broken links.

When you create a list or a document library in SharePoint, you will notice that by default, the list or the document library link has been added to the Quick Launch on the left hand side of your site, Unless Quick Launch has been disabled. That kind of link upgrades with no issues since it is a relative link that SharePoint knows about and knows how to call and reference. However, when users, such as site owners, manipulate the Quick Launch navigation and add additional links, they manually type in the address and description, so that it is easier for their end users to access the link content, that link is what gets broken after an upgrade.

So the question of updating broken link is often a common one. Below we address this common concern to a certain extent. Obviously, hard coded links can be anywhere, on the links web part, inside of documents, on the top link bar, and on the native site Quick Launch.

Below is a script and a video that updates Quick Launch absolute links to relative URLs.

Note: You will have to upate the first four lines of the script your site scope, the quick launch heading, the absolute url you want to change, and the relative url you want to change to.

$site = “http://sharepoint2010/sites/SPQuester
$QuickLaunchHeading = “Libraries”
$absoluteUrl = “http://sharepoint2003/sites/SPQuester/Shared Documents”
$relativeUrl = “./Shared Documents” 
foreach ($web in (Get-SPSite  $site | Get-SPWeb -Limit All))
{
    $node = $web.Navigation.QuickLaunch | where { $_.Title -eq $QuickLaunchHeading }    foreach($childNode in $node.Children | where { $_.URL -eq ($absoluteUrl) })
    {
        Write-host “Updating” $childNode.Title “on the following site” $web.Url
        $childNode.URL = $relativeUrl
        $childNode.Update() 
    }
    $web.Update()
    $web.Dispose()
}
Write-host “Completed Successfully”

Video Length: 2:55

List Site Templates and IDs in SharePoint 2010 Using Windows PowerShell

One of the main checkpoints you will have to worry about as you upgrade or migrate SharePoint sites across farms or versions are custom site templates and how they are handled during migrations. You may upgrade or migrate custom site templates as is or you may elect to re-template site templates. A perfect place to start would be to know what custom site templates you have. So I did some research and finally stumbled upon a couple of scripts that I want to share with you. These scripts will help you:

  • List all site collections within a web application <– This will give us a better understanding of the total number of sites we may consider for migrations
Get-SPWebApplication “http://WebAppAddress“| Get-SPSite -limit ALL|Get-SPWeb -limit ALL|Select-Object Title,Url
  • List all site templates and template IDs for a given web application <– So we end up knowing what is standard and what is custom
$webapp = Get-SPWebApplication -identity http://WebAppAddress/
$webtem = Get-spwebtemplate
foreach ($site in $webapp.Sites)
{
 $spweb = get-spweb $site.URL
 write-host “Site URL: ” $site.URL
 write-host “Web Template: ” $spweb.WebTemplate
 write-host “WebTemplateID: ” $spweb.WebTemplateID
 write-host “————————————-”
}
  • List site template and site ID for a given site <– If there is a specific site we want to migrate and are interested in knowing what template it was created from
$web = Get-SPWeb http://webapp/sites/site/subsiteaddress
write-host “Web Template:” $web.WebTemplate ” | Web Template ID:” $web.WebTemplateId
$web.Dispose()
  • In general a list of all site templates available <– If you just want to see what site templates you have
 Get-SPWebTemplate | Sort-Object “Name”

I’ve recorded a short video to demonstrate the above.

Video length: 3:56

Ghazwan Khairi

SharePoint Quester

Using the Datasheet View to Bulk Update SharePoint 2010 List Columns

As I was digesting my SharePoint caffeine dose for the day, I came across a question that asked if there is a way to perform bulk updates on a SharePoint list column so I figured that is easy enough to record and share.

I know this can probably be done with PowerShell, but I used the Datasheet View along with the “Fill Down” action to demonstrate how that can be done. Enjoy!

Video length: 2:30

Ghazwan Khairi | a.k.a SharePoint Quester