Being involved in migrations for past couple of years, one of the pain area is to verify the migrated content. There are some amazing migration tools like Sharegate, Metalogix, AvePoint and they provide some very useful reports to verify the content but still I haven’t seen a report which can compare the migrated content in two sites, like which lists are migrated and how much content is migrated. We can check the migrated list names on migration tool. Metalogix provides item count on the Migration console window but still we need a report which can be used for document it properly.

The default solution is to open site content of source and destination sites and compare all the lists and item count manually. To minimize that effort, I have written a PowerShell script for SharePoint online which can generate a very useful report to verify the migrated lists and item count in two sites.

To make it easier for end user, I created a function PostMigrationComparisonReport, which take Source site URL and Destination Site URL as parameter. I did this job for migrating content with same tenant, so I used a single user account. If you are migrating content to separate office 365 site, then you need call the Get-Credential function for destination site separately for destination context. I used the credentials of both source and destination lists.

Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"


function PostMigrationComparisonReport($siteUrlSource, $siteUrlDestination)
{
    #*** if you are migrating content to separate office 365 site then you need call the Get-Credential function for destination site separately. ***   
    $Cred= Get-Credential
    $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

    $ctxSource = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrlSource) 
    $ctxSource.Credentials = $credentials 

    $ctxDestination = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrlDestination) 
    $ctxDestination.Credentials = $credentials 

    $webSource = $ctxSource.Web  

    $listsSource = $webSource.Lists
    $ctxSource.Load($listsSource)
    $ctxSource.ExecuteQuery()

    $webDestination = $ctxDestination.Web  

    $listsDestination = $webDestination.Lists
    $ctxDestination.Load($listsDestination)
    $ctxDestination.ExecuteQuery()

    Write-Host -ForegroundColor Yellow "The site URL is" $webSource.Title
    Write-Host -ForegroundColor Yellow "The dest site URL is" $webDestination.Title
    $tableListNames =@();
    #output the list details
    Foreach ($listSource in $listsSource)
    {
        Write-Host -ForegroundColor Yellow "List name: " $listSource.Title;
        $o = new-object psobject
  
        $o | Add-Member -MemberType noteproperty -Name "sListName" -value $listSource.Title;
        $o | Add-Member -MemberType noteproperty -Name "sNo. of Items" -value $listSource.ItemCount;
        $o | Add-Member -MemberType noteproperty -Name "sLastItemModifiedDate" -value $listSource.LastItemUserModifiedDate;
            
        $o | Add-Member -MemberType noteproperty -Name dListName -value NotSet;
        $o | Add-Member -MemberType noteproperty -Name dItemsCount -value NotSet;
        $o | Add-Member -MemberType noteproperty -Name dLastItemModifiedDate -value NotSet;
    
        Foreach ($listDestination in $listsDestination)
        {
            if ($listSource.Title -eq $listDestination.Title)
            {
            Write-Host -ForegroundColor Green "List name: " $listDestination.Title;
                $o.dListName = $listDestination.Title;
                $o.dItemsCount = $listDestination.ItemCount;
                $o.dLastItemModifiedDate = $listDestination.LastItemUserModifiedDate;
                break;
            }
        }
        $tableListNames += $o;
    }
    return $tableListNames;
}

The script is written to compare content between two sites for SharePoint online, but if your migration source is SharePoint Server environment like SharePoint 2010, SharePoint 2013, SharePoint 2016 or 2019 then you can change the PowerShell script, so it can fetch the list and item count detail from on-premise environment.

Now, you need to call the function PostMigrationComparisonReport and pass the source and destination site URLs as parameters and execute the function.

PostMigrationComparisonReport "https://MsTalk.sharepoint.com/MsTechTalkSource" "https://MsTalk.sharepoint.com/sites/MsTechTalkDestination" | Out-GridView

Or export output as csv file where you can have the excel view.

PostMigrationComparisonReport "https://MsTalk.sharepoint.com/MsTechTalkSource" "https://MsTalk.sharepoint.com/sites/MsTechTalkDestination" | ExportCsv -Path "C:\ PostMigrationComparisonReport.csv"

SharePoint Migration Compare two sites

Adnan, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply