1

I've backed up over 200 sub sites and restored them to a new site collection with it's own content database. I want to do a quick compare of the document libraries to make sure nothing was missed.

I found the following that compares two lists, is there anything that compares two document libraries?

$oldReviewSite = Get-SPweb "http://portal.com/siteA"

$newReviewSite = Get-SPweb "http://portal.com/siteB"


$aList = $oldReviewSite.lists["Agenda"]
$bList = $newReviewSite.lists["Agenda"]


$arrA = @()
$arrB = @()

foreach($iA in $aList.Items)
    {
 $arrA += $iA["Title"]
}

foreach($iB in $bList.Items)
{
 $arrB += $iB["Title"]
}

$c = Compare-Object -ReferenceObject $arrA -DifferenceObject $arrB -PassThru
Write-Host $c

I just need a simple PS script for now. I can expand it to iterate through the list of 200+ sites.

1 Answer 1

1

Document libraries are derived from lists under the covers. So your example above should also work for a document library.

Take a look at this example from another question previously posted. You can see the code is very similar:

Traverse through List of Documents using PowerShell

1
  • Thanks Erik, you were correct, I was able to list all the documents and compare them. I'm not sure what I was doing wrong before but I did get it working!
    – Marker
    Commented Jan 26, 2016 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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