Skip to content

Instantly share code, notes, and snippets.

@aadennis
Last active March 1, 2017 21:48
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 aadennis/c98d948bcbb9dced9c6188299da7bdea to your computer and use it in GitHub Desktop.
Save aadennis/c98d948bcbb9dced9c6188299da7bdea to your computer and use it in GitHub Desktop.
Config settings
{
"ComparisonSettings": {
"BaseFolder":"c:/temp/comparer",
"SourceFolder": "Version971",
"TargetFolder": "Version972",
"WildCardSet": "x.x,y.y"
}
}
# 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
}
@aadennis
Copy link
Author

aadennis commented Mar 1, 2017

Testing the

comments

and

  1. stuff1
  2. stuff2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment