title: Compare Permissions of two folders at different locations
body: <p>I m trying to write a script to compare permissions of two folders at two different locations. The Folder name at both locations would be the ADID of an user and some users may have two or more AD accounts. </p>
  
  <pre><code>$OutPath = ".\out1.csv"
  
  $sourcepath1 = Get-Content ".\mwd_src.txt" 
  foreach ($path1  in $sourcepath1) {
      $name1 = (Get-Item $Path1).name
      $FolderAcl1 = (Get-Acl $Path1).Access | Select-Object IdentityReference
  
      $Source = $FolderAcl1 | Where-Object { $_.IdentityReference -like "*$name1*"} |
          Select-Object @{ Label = "Path"; Expression = { echo $Path1 } }, @{ Label = "Access"; Expression = { $_.IdentityReference } }
  }
  
  $sourcepath2 = Get-Content ".\mwd_dest.txt"
  foreach ($path2 in $sourcepath2) {
      $name2 = (Get-Item $Path2).Name
      $FolderAcl2 = (Get-Acl $Path2).Access | Select-Object IdentityReference 
      $Dest = $FolderAcl2 | Where-Object { $_.IdentityReference -like "*$name2*" } |
          Select-Object @{ Label = "Path"; Expression = { echo $Path2 } }, @{ Label = "Access"; Expression = { $_.IdentityReference } }
  }
  
  $Source1 = $Source | Select-Object -Unique
  $Dest1 = $Dest | Select-Object -Unique
  
  $Out = Compare-Object -ReferenceObject $Source1 -DifferenceObject $Dest1
  $Out1 = $Out | Where-Object { $_.SideIndicator -match "=&gt;" }
  
  foreach($OutItem in $Out1) {
      $Outitem.InputObject | Add-Content $OutPath
  }
  </code></pre>
  
  <p>But getting the following error</p>
  
  <p>"Compare-Object : Cannot bind argument to parameter 'DifferenceObject' because it is null.
  "</p>
  
  <p>Please assist.</p>