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

    $webDestination = $ctxDestination.Web  

    $listsDestination = $webDestination.Lists

    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;
        $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 "" "" | Out-GridView

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

PostMigrationComparisonReport "" "" | ExportCsv -Path "C:\ PostMigrationComparisonReport.csv"

SharePoint Migration Compare two sites

Adnan is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply