I've been playing with Powershell for some time now, pretty much since it was still codenamed 'Monad' (I say 'playing' as the only PS scripts that I've put into production have been at home as all my scripting at work is still either VBscript of old-school .cmd). If you've done anything with Powershell you'll know how easy it is to get stuff done in considerably less code than would normally be required with VBS. At one of the sessions I attended at TechEd last year, Jeffrey Snover the architect behind Powershell said he'd seen examples of massive code reduction, the best behind 481 lines of VBS down to 1 line of Powershell. Hmm, so far rewriting some of my scripts from VBS to Powershell have only achieved about 50% code reduction but given my coding skills (!) that's pretty impressive. Still, it gives me a target to work to I suppose...
Anyway, I've been working on a PS script part of which was the need to compare two pretty big file listings and I'd reached a point where I was going to have to export the output and use some other method of comparing to identify the differences...until I checked out my RSS feeds this morning and there was my answer: compare-object. Trust me, at this point I probably felt as foolish as the acquaintance who once decided to swap carriages on the Alton Towers monorail at the last minute only to be left standing on the platform as I amongst others mocked him from the quickly departing train. Anyway...
$compare1 = (gci c:\path1 -recurse where {!$_.PsIsContainer})
$compare2 = (gci c:\path2 -recurse where {!$_.PsIsContainer})
compare-object $compare1 $ompare2
...got the desired result, so todays blog of the day (other than this one ha, ha!) is Dreaming In Powershell.
Anyway, I've been working on a PS script part of which was the need to compare two pretty big file listings and I'd reached a point where I was going to have to export the output and use some other method of comparing to identify the differences...until I checked out my RSS feeds this morning and there was my answer: compare-object. Trust me, at this point I probably felt as foolish as the acquaintance who once decided to swap carriages on the Alton Towers monorail at the last minute only to be left standing on the platform as I amongst others mocked him from the quickly departing train. Anyway...
$compare1 = (gci c:\path1 -recurse where {!$_.PsIsContainer})
$compare2 = (gci c:\path2 -recurse where {!$_.PsIsContainer})
compare-object $compare1 $ompare2
...got the desired result, so todays blog of the day (other than this one ha, ha!) is Dreaming In Powershell.
No comments:
Post a Comment