Friday, January 6, 2012

Powershell (v2) - Remove-Item (Passing Collections to Cmdlet)

After working to get some quick file generation script, I added on this one to delete files quickly as a collection:
$files = dir .;
$files | Remove-Item
I noted on Twitter that a cool hack would be doing something like this:
$files = dir .;
$files.Remove()
Or, to shorten it up even more:
(dir .).Remove();
Ah, the power of imagination.

0 comments:

Post a Comment