Skip to content

Instantly share code, notes, and snippets.

@pezhore
Created October 25, 2017 15:50
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 pezhore/f7175fe490ce351749ac1898c56e2cad to your computer and use it in GitHub Desktop.
Save pezhore/f7175fe490ce351749ac1898c56e2cad to your computer and use it in GitHub Desktop.
# Import CSVs
$csv1 = Import-CSV -Path c:\temp\csv1.csv
$csv2 = Import-CSV -Path c:\temp\csv2.csv
# Loop through each item in csv1
foreach ($item in $csv1) {
$thisDataType = $item.DataType
# find the entry in csv2 where csv2's column name matches this column name
$csv2DataType = ($csv2 |Where-Object {$_."Column Name" -match $item."Column Name"}).DataType
# If the two don't match, say so
if (! $thisDataType -eq $csv2DataType){
Write-Output "CSV2 datatype does not match CSV1 datatype for Column Name $($item.'Column Name')"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment