Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Last active May 3, 2016 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellwest/309c6a49ff3946e984a39242353ebc4e to your computer and use it in GitHub Desktop.
Save michaellwest/309c6a49ff3946e984a39242353ebc4e to your computer and use it in GitHub Desktop.
Compares the different between two folders.
function Compare-Folder {
param(
[string]$LeftFolder,
[string]$RightFolder
)
$LeftSideHash = Get-ChildItem $LeftFolder -Recurse | Get-FileHash -Algorithm SHA1 |
Select-Object @{Label="Path";Expression={$_.Path.Replace($LeftFolder,"")}},Hash
$RightSideHash = Get-ChildItem $RightFolder -Recurse | Get-FileHash -Algorithm SHA1 |
Select-Object @{Label="Path";Expression={$_.Path.Replace($RightFolder,"")}},Hash
Compare-Object $LeftSideHash $RightSideHash -Property Path,Hash | Sort-Object -Property Path
}
Compare-Folder -LeftFolder "C:\inetpub\wwwroot\Console\Website\App_Config\Include" -RightFolder "C:\inetpub\wwwroot\Console2\Website\App_Config\Include"
Compare-Folder -LeftFolder "C:\inetpub\wwwroot\Console\Website\bin" -RightFolder "C:\inetpub\wwwroot\Console2\Website\bin"
Import-Module -Name SPE
$folderFilter = "^archive\\|^App_Data\\|^sitecore\\|^sitecore modules\\|^temp\\"
$script = {
$directory = "$AppPath"
Get-ChildItem $directory -Recurse |
Where-Object { $_.FullName.Replace($directory,"") -notmatch $using:folderFilter } |
Get-FileHash -Algorithm SHA1 |
Select-Object @{Label="Path";Expression={$_.Path.Replace($directory,"")}},Hash
}
$session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://sctsta.console.com"
$leftSide = Invoke-RemoteScript -ScriptBlock $script -Session $session
$session = New-ScriptSession -Username "admin" -Password "b" -ConnectionUri "http://sctstd.console.com"
$rightSide = Invoke-RemoteScript -ScriptBlock $script -Session $session
Compare-Object $leftSide $rightSide -Property Path,Hash | Sort-Object -Property Path
$LeftFolder = "C:\inetpub\wwwroot\Console\Website\"
Get-ChildItem $LeftFolder -Recurse |
Where-Object { $_.FullName.Replace($LeftFolder,"") -notmatch "^App_Data\\|^sitecore\\|^sitecore modules\\|^temp\\" } |
Get-FileHash -Algorithm SHA1 |
Select-Object @{Label="Path";Expression={$_.Path.Replace($LeftFolder,"")}},Hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment