06 June,2012 by Tom Collins
Question: As part of a nightly ETL process , a bunch of folders\files are copied from one location to another. The contents of the folders are processed via a SSIS job. How can I validate the copy is successful?
Answer: Compare-Object Powershell can compare the contents of the folder and report on differences. Build in a compare step before the SSIS process step . If there are differences after the copy , trap the error and log the difference
The Compare-Object cmdlet compares two sets of objects i.e Reference Set and Difference Set
copy .\difftest1\* .\difftest2$dir1 = Get-ChildItem .\difftest1 -Recurse$dir2 = Get-ChildItem .\difftest2 -RecurseCompare-Object $dir1 $dir2 -IncludeEqual$diff = Compare-Object $dir1 $dir2if($diff){ "WARNING: There are differences between the source and target folders"}else{ "SUCCESS:The folder contents copied successfully"}
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |