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