In the process of migrating between MOSS 2007 and SharePoint 2010 I needed to get a listing of all Email Enabled Document Libraries/Lists in my MOSS 2007 environment prior to migration. This could be accomplished with a little bit of coding with the SharePoint API, but why do that when you can do it with PowerShell.
First and foremost if you haven’t already installed PowerShell 2.0 onto your MOSS 2007 server go to http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=20430 and download the lastest version. Since PowerShell does not come native with MOSS 2007 this needs to be installed individually before we can begin.
After installing PowerShell 2.0 we are going to be creating a .ps1 file.
Open up any text editor (my choice is notepad).
First thing we want to do is load the SharePoint Assemblies so that PowerShell knows how to process MOSS 2007 commands. Assemblies do not have to be loaded into SharePoint 2010.
#Load SharePoint Assemblies
[System.reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
Next Instantiate a SPWebApplication Object
#Instantiate a SPWebApplication Object
$SPWebApp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup(http://portal)
Next Lets Create a CSV file
#Create a CSV file Email-Enabled.txt
“E-Mail,List,Site” > “EMail-Enabled.txt” #Write the Headers in to a text file
Now Create a ForEach loop to loop through the SharePoint Web Applications, Sites, Subsites, and Lists to gather all Email Enabled Document Libraries and pipe it out to the Email-Enabled.Txt file we created.
foreach ($SPsite in $SPwebApp.Sites) # Get The Collection of Site Collections
{
foreach($SPweb in $SPsite.AllWebs) # Get The Collection of Sub Sites
{
foreach ($SPList list in $SPweb.Lists) # Get The Collection of Lists.
{
if ( ($splist.CanReceiveEmail) -and ($SPlist.EmailAlias) )
{
# WRITE-HOST “E-Mail -” $SPList.EmailAlias “is configured for the list “$SPlist.Title “in “$SPweb.Url
$SPList.EmailAlias + “,” + $SPlist.Title +”,” + $SPweb.Url >> EMail-Enabled.txt #append the data
}
}
}
}
So your final script should look like this:
#Load SharePoint Asssemblies
[System.reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
[System.Reflection.Assembly]::Load(“Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
$SPWebApp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup(http://portal)
#create a CSV file
“E-Mail,List,Site” > “EMail-Enabled.txt” #Write the Headers in to a text file
#Create foreach loop to enumerate through SharePoint Web Application, Sites, Subsites, and Lists.
foreach ($SPsite in $SPwebApp.Sites) # get the collection of site collections
{
foreach($SPweb in $SPsite.AllWebs) # get the collection of sub sites
{
foreach ($SPList list in $SPweb.Lists)
{
if ( ($splist.CanReceiveEmail) -and ($SPlist.EmailAlias) )
{
# WRITE-HOST “E-Mail -” $SPList.EmailAlias “is configured for the list “$SPlist.Title “in “$SPweb.Url
$SPList.EmailAlias + “,” + $SPlist.Title +”,” + $SPweb.Url >> EMail-Enabled.txt #append the data
}
}
}
}
Save the file as emailenabled.ps1 or which ever name you choose.
Open up PowerShell on your MOSS 2007 Server, and change directories to where the emailenabled.ps1 script was saved.
Execute the script. Depending on how large your web application is this might take a little bit of time.
After the script completes inside the location where your script sits you will now see a .TXT file named “Email-Enabled.txt”. Inside that text file you will have a listing of all the Email Enabled Document Libraries/Lists within your SharePoint 2007 Web Application.
Image may be NSFW.
Clik here to view.
Clik here to view.
