-
-
Save aadennis/c98d948bcbb9dced9c6188299da7bdea to your computer and use it in GitHub Desktop.
Config settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ComparisonSettings": { | |
"BaseFolder":"c:/temp/comparer", | |
"SourceFolder": "Version971", | |
"TargetFolder": "Version972", | |
"WildCardSet": "x.x,y.y" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compare the content of a pair of folders using | |
# command line Beyond Compare | |
cd C:/sandbox/PowerShell/CompareProject | |
# First needs to know where to get the configuration file... | |
# As this is a json file, parse it outside of PS to ensure that it is well-formed | |
$global:BaseDirectory = "C:/sandbox/PowerShell/CompareProject/" | |
$global:BaseConfig = "config.json" | |
try { | |
$configFile = "$BaseDirectory$BaseConfig" | |
if (!(Test-Path -Path $configFile)) { | |
Write-Error -Message "Configuration file [$configFile] not found. Exiting..." -WarningAction | |
throw | |
} | |
$configFile | |
$global:Config = Get-Content $configFile -Raw | ConvertFrom-Json | |
$global:Config | |
${global:$} | |
# validate expected values are not null (improve this to previously save to an array) | |
$configPropertySet = $null | |
$configPropertySet = @{} | |
$baseFolder = $Config.ComparisonSettings.BaseFolder | |
$configPropertySet.Add("BaseFolder", $baseFolder) | |
$configPropertySet.Add("SourceFolder", [string]::Format("{0}/{1}", $baseFolder, $Config.ComparisonSettings.SourceFolder)) | |
$configPropertySet.Add("TargetFolder", [string]::Format("{0}/{1}", $baseFolder, $config.ComparisonSettings.TargetFolder)) | |
$configPropertySet.Add("WildCardSet", $($config.ComparisonSettings.WildCardSet).Split(",")) | |
# Exit if any properties are null... | |
$configPropertySet.Keys | % { | |
$currentKey = $_ | |
"Checking [$currentKey]..." | |
if ($configPropertySet[$currentKey] -eq $null) { | |
"The value for [$currentKey] is empty. Exiting..." | |
throw | |
} | |
} | |
"Number of configuration properties: [$($configPropertySet.Count)]" | |
$configPropertySet.Keys | % { | |
$currentKey = $_ | |
"${currentKey}: [$($configPropertySet[$currentKey])]" | |
} | |
$wildCardSet = $configPropertySet["WildCardSet"] | |
$wildCardSet[0] | |
$wildCardSet[1] | |
} | |
catch { | |
"Here now" | |
throw | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testing the
and