Sep 10, 2009

Customize the My Site Portal Link

I’m waiting for two buttons from our designer, so I’ve got 10 minutes for trivial post…

One of our customers has already created hundreds of My Sites, but unfortunately all this sites are missing the portal link to the intranet. Two simple requirements: all new sites should have the portal link automatically and all existing sites should get the portal link too.

image

  1. Customizing the portal link of the root My Site site takes care that the portal link will automatically added to new my sites. You have to enter the url to the setting page directly (e.g. http://localhost:8020/_layouts/portal.aspx), otherwise you get routed to your My Site.
  2. To migrate all existing My Sites I’ve written a simple PowerShell script – what else ;-)
# Set-SPPortalLink.ps1
# e.g. . .\Set-SPPortalLink "http://localhost:81/" "Intranet" "http://intranet"

param($webAppUrl, $portalName, $portalUrl)

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$webApp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($webAppUrl)

foreach($site in $webApp.Sites)
{
$site.Url | Out-Host
#impersonate site to system user
$impSite = new-object Microsoft.SharePoint.SPSite($site.ID, $site.SystemAccount.UserToken)
$impSite.PortalName = $portalName
$impsite.PortalUrl = $portalUrl

$impSite.Dispose()
$site.Dispose()
}

0 comments: