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. ***
$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
#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;
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"
Latest posts by Adnan Amin (see all)
- SharePoint folder deletion error: Cannot delete/checked out issue - March 5, 2019
- Get list of all hidden lists in a SharePoint Site - February 27, 2019
- SharePoint Modern UI: Using Sites web part page - February 19, 2019