Home > PowerShell, SharePoint 2010 > Get a Listing of Hyperlinks in SharePoint 2010 using PowerShell

Get a Listing of Hyperlinks in SharePoint 2010 using PowerShell

I needed to grab a listing of all hyperlinks in my SharePoint 2010 web apps that had referenced links that linked back to our old SharePoint 2007 environment as a post cleanup after a data migration.

Below is the PowerShell script I used to get me that list.

=======================================================================

$webApp = Get-SPWebApplication “http://portal

#Write headers for .csv file

“listURL `t” + “listName `t” + “Item/Link Name `t” + “linkURL” >> HyperLinks.csv

#iterate through the lists

foreach ($webs in $webApp | Get-SPSite -Limit All | Get-SPWeb -Limit All)
{
foreach ($list in $webs.Lists)
{
#Find all hyperlink fields in list
$fields = @()
foreach ($field in $list.Fields)
{
if ($field.TypeAsString -eq “URL”)
{
$fields = $fields + $field.Title
}
}
#Skip list because there are no hyperlink fields
if ($field.Count -eq 0) {continue}

#iterate through list items
foreach ($item in $list.Item)
{
foreach ($field in $fields)
{
$fldValue = $item[$field]
if (fldValue -ne $null)
{
#if statement if you want to check for a specific URL, if not no need for if statement

if ($fldValue -like “http://oldportal/*”)
{
$webs.Url + “/” + $list.RootFolder.Url + “`t” + “$list.title” + “`t” + $item.Name + “`t” + fldValue >> HyperLinks.csv
}
}
}
}
}
}

Advertisements
  1. August 8, 2013 at 12:22 am

    Everything is very open with a clear explanation of the issues.

    It was definitely informative. Your site is extremely helpful.
    Thanks for sharing!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: