Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I get list of users which have their own documents stored in My Sites (MOSS 2007)? Or even better, all their documents together with names? It dosen't matter if it will be via script or GUI. I just know that we have some users with documents in old portal and I must transfer it somehow to the new My Sites on SP 2010. Thank you.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I would create a powershell script that loops through all the user profiles. Retrieves the PersonalSite of that user and list the files that reside in a certain document library. The script below should be able to list the URL of all the files that are inside the document libraries 'Personal Documents' and 'Shared Documents'.

#Load the required SharePoint DLL's for this script
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")

$siteUrl = "http://yourdomain"
$documentLibrariesToScan = "Personal Documents", "Shared Documents"

#Get the UserProfileManager
$site = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$serverContext = [Microsoft.Office.Server.ServerContext]::GetContext($site)
$userProfileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serverContext)

foreach($userProfile in $userProfileManager) 
{
    Write-Host $userProfile["AccountName"]

    #Get the personal site of the user. 
    $personalSite = $userProfile.PersonalSite
    if($personalSite -ne $NULL)
    {
        foreach($documentLibraryName in $documentLibrariesToScan)
        {
            #Check the specified document libraries.
            $documentLibrary = $personalSite.RootWeb.Lists[$documentLibraryName]

            if($documentLibrary -ne $NULL)
            {
                foreach($item in $documentLibrary.Items)
                {
                    #Write all the urls of the files found in the document library.
                    Write-Host $item.File.Url
                }
            }
        }
        $personalSite.Dispose()
    }
}
$site.Dispose()
share|improve this answer
    
I'm sorry, I'm not able to run this script. If I substitute variables with almost everything that come to my mind, I get only "web application could not be found" error. Address in what form must be typed in please? –  Molik Aug 9 '11 at 13:40
    
You should use the address of your SharePoint site, so not your SSP. If it runs on a specific port then also add that, like 'http: //your.domain.com:54321>'. It will create an SPSite object and retrieve the the SSP / UserProfileManager that is used for the SPSite. –  Remco Eissing Aug 10 '11 at 7:06
    
> It works! The trick was to run this script on the right server. My apologies, I tried to run it from our maintenance server with administration & migration tools all the time. Thank you! –  Molik Aug 18 '11 at 7:25
    
The only one thing, script listed only public (shared) documents, can I somehow get all docs in libraries please ? Some users have "Unable to index into an object of type Microsoft.SharePoint.SPListCollection" error in log, is it possible, that they have another library with another documents beside the shared ones ? –  Molik Aug 18 '11 at 8:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.