![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Comparison of two sets of Data I believe this is going to involve arrays and would like some guidance But basically I want to write a list of these that don't match after a comparison of the two sets of data. In the following format obviously when the outer foreach doesn't match the nested foreach it writes a "notmatch" - even if there is a match within the two sets of data. $CSVFile = "D:\Clusters.csv" $Directory = "D:\Clusters" $clusterfiles = dir $Directory | get-childitem -name $ICLUSTERS = Import-Csv $CSVFile ForEach ($ICLUSTER in $ICLUSTERS){ $Cluster = $ICLUSTER.cluster ForEach ($clusterfile in $clusterfiles){ $clusfile = $clusterfile.name $clusfilename = $clusterfile.split(".")[0] if ($Cluster -notmatch $clusfilename){ write-host $Cluster " not match" }#if }#foreach }#foreach -- jobbsy@xxxxxx |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Comparison of two sets of Data Check out compare-object. I have used this a few times recently, it's really easy and flexible. $previous = import-clixml "D:\LastResults.xml" $current = dir "D:\directory" compare-object $previous $current -Property name -IncludeEqual $current | export-clixml "D:\LastResults.xml" Drop the -IncludeEqual to just see the changes. You can swap out name for size, or compare multiple properties. Very handy! Adrian On May 11, 12:51*pm, Jobbsy <Job...@xxxxxx> wrote: Quote: > I believe this is going to involve arrays and would like some guidance > > But basically I want to write a list of these that don't match after a > comparison of the two sets of data. > > In the following format obviously when the outer foreach doesn't match the > nested foreach it writes a "notmatch" - even if there is a match within the > two sets of data. > > $CSVFile = "D:\Clusters.csv" > $Directory = "D:\Clusters" > $clusterfiles = dir $Directory | get-childitem -name > $ICLUSTERS = Import-Csv $CSVFile > > ForEach ($ICLUSTER in $ICLUSTERS){ > $Cluster = $ICLUSTER.cluster > > * * * * ForEach ($clusterfile in $clusterfiles){ > * * * * * * $clusfile = $clusterfile.name > * * * * * * $clusfilename = $clusterfile.split(".")[0] * * * * > > * * * * * * * * * * if ($Cluster -notmatch $clusfilename){ > * * * * * * * * * * write-host $Cluster " not match" > * * * * * * * * * * }#if > > * * * * }#foreach > > }#foreach > > -- > job...@xxxxxx |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Comparison of two sets of Data take note that compare-object compares up to 15 items. Therefore to compare unlimited items, put: compare-object -syncWindow $int where $int is higher of the 2 objects. Eg compare-object <source> <target> -syncWindow $int |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Box sets in MB | Media Center | |||
| A Comparison | Graphic cards | |||
| Two sets of folders | Live Mail | |||
| Backup sets | Vista General | |||
| Running Two Sets Of Speakers | Vista General | |||