Beginner Event 4:
ForEach($item in (Compare-Object (Get-Childitem "C:\1") (Get-Childitem "C:\2"))){$item.InputObject}
Although normally I would prefer to break it out a bit more to something like this (although it does exactly the same thing):
$Differences=(Compare-Object (Get-Childitem "C:\1") (Get-Childitem "C:\2")) ForEach($item in $Differences) { $item.InputObject }
UPDATE:
I probably would've lost a point or two, as there is an even easier way to do that using the "-PassThru" option...
Compare-Object (Get-Childitem "C:\1") (Get-Childitem "C:\2") -Property Name -PassThru
1 comment:
Sounds like you figured out that you were looking for the -PassThru parameter. Other than that, you were on the right track.
Here's what I submitted for this one:
http://2012sg.poshcode.org/3575
And the blog I wrote about it:
http://mikefrobbins.com/2012/04/13/just-passing-thru-2012-powershell-scripting-games-beginner-event-4/
Mike F Robbins
http://mikefrobbins.com
Post a Comment