Archive for October, 2009

Testing access to SharePoint pages

Let’s say you have a long list of SharePoint pages that need to be tested to verify that they’re permissioned correctly.  One way to do it is to take a non-privileged account (end user) and attempt to connect to each of the URLs.  If the page is locked down, you’ll get a page titled “Access denied”; otherwise, the page will load normally.

I recently responded to a thread on SharePoint TechNet about a similar issue and ended up writing a PowerShell script to address it.

The script below will read a text file containing a list of URLs (make sure to modify the source file path with your own path), and then call a function for each URL.  This function will open a new instance of IE, navigate to the URL, wait for the page to load, and then grab the title of the page.  If the user doesn’t have access to the page, the page title will contain “Access denied”; otherwise, the page title will be returned.  Run this script under the credentials of one of your end users.  If you’re trying to open individual documents (Word, Excel, etc.), you may need to modify the script so that it launches correct application (and closes it when done).


# This script will read a text file containing a list of URLs and attempt to connect to each URL.  Successful connection will return the page's title; otherwise, the script will return Access denied error.

# OpenIE function starts here...
# This function launches a new instance of IE and then navigates to the specified URL

function OpenIE($url)
{

if ($url -notlike "http://*")
{

$url = "http://" + $url

}
$ie = new-object -com "InternetExplorer.Application"

$ie.Visible = $true

$ie.Navigate($url)

# wait for IE to load the page

While( $ie.Busy )
{
[System.Threading.Thread]::Sleep(100)
}

# grab page title - if access is denied, the page title will say so

$Title = $ie.Document.Title

$ie.Quit()

return $Title

}

 

# *** Main script routine starts here ***
# specify your source file path here...

$SourceFilePath = "C:\Shared\list.txt"

write-host "Starting script..."

# read the source file into an array of strings, iterate through each one

$list = Get-Content $SourceFilePath

foreach ($item in $list)
{

$result = OpenIE($item)

write-host $item, ";" , $result

}

write-host "Finished."

Maximum string length for SharePoint profile custom properties

Today I needed to create a custom property in SharePoint which would store some long strings.  So naturally, a question came up:  How long can a string be before SharePoint refuses to recognize it?  It appears that the limit is set at 2,000 characters.  When I tried setting the string field length to 2,000 characters and attempted to save the new property, SP would reset it back to the default value of 25.  However, it does accept 1,999 characters or less (see screenshot below). 

SomeCustomProperty

Presenting at the LexMUG October meeting

I presented at the Lexington Microsoft Users Group (www.lexmug.com) meeting today on the topic of functional differences between WSS 3.0 and MOSS 2007.

https://sharepointnomad.files.wordpress.com/2009/10/lexmug_oct2009_presentation-andregalitsky.ppt

Finding out where SharePoint email alias is used

Recently, a question came up in the SharePoint TechNet forums regarding document libraries with incoming email enabled.  If you only know the name of the AD contact for the library, how can you find out which document library or list it’s pointing to? 

Here’s a straightforward PowerShell script which will iterate through every site collection in every web application and return the names and email aliases of every list that has an active email alias specified.


[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

[void][System.reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$oContentService = [Microsoft.Sharepoint.Administration.SPWebService]::ContentService;

[Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.webApplications;

$waColl1 = $waColl | where-object {$_.IsAdministrationWebApplication -eq $FALSE}
write-host "WebApplication; Site Collection; List Title; List URL; EmailAlias"

foreach ($wa in $waColl1)
{

$sites = $wa.Sites

foreach ($obj in $sites)

{

$spSite = new-object Microsoft.SharePoint.SPSite($obj.URL)

$colWebsites = $spSite.AllWebs

foreach ($web in $colWebsites)
{

 $colLists = $web.Lists
 
 foreach ($list in $colLists)
 {

 if ( $list.EmailAlias -ne $null )
 {

 write-host  $wa.Name, ";", $obj.URL, ";", $list.Title , ";", $list.DefaultViewUrl, ";",  $list.EmailAlias

 }

 }

}

}

}

write-host "Finished."

Finding out where a list column is used in a site collection

There are times when you need to know where a specific list column is being used in your site collection. This is especially true for custom columns that you may have created. The following script can be used to find which lists are using a specific column name. (I posted this script on the SharePoint TechNet forum in response to a question.)


[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null

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

# set-up working variables...

# Enter your SharePoint site collection URL here...

$TargetSiteUrl = "http://sharepoint_site_collection_URL"

# Enter the list column name you want to find here...

$FieldToFind = "Title"

# Starting search

write-host "FieldName, ListName, ListURL"

$spSite = new-object Microsoft.SharePoint.SPSite($TargetSiteUrl)

$colWebsites = $spSite.AllWebs

foreach ($web in $colWebsites)
{

$colLists = $web.Lists

foreach ($list in $colLists)
{

$fields = $list.Fields

foreach ($item in $fields)
{

If ($item.Title.Contains($FieldToFind))
{
write-host  $item.Title, ";", $list.Title, ";", $list.DefaultViewUrl
}

}

}

}

write-host "Finished."


RSS Information Week Headlines

  • An error has occurred; the feed is probably down. Try again later.

RSS SharePoint Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS InfoPath Team Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Joel Oleson Blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Bud Ratliff blog

  • An error has occurred; the feed is probably down. Try again later.

RSS Susan Hanley’s KM Blog

  • An error has occurred; the feed is probably down. Try again later.

Blog Stats

  • 401,900 hits