03 Nov 2011 @ 5:48 AM 

In the category of scripts to clean up computers, here is a one-liner for removing all files but leaves the directory structure intact.

I found this to be very useful for companies that have a network share where every user has it’s own directory but company policy states that all files will be deleted from that share in the weekend.

ls -recurse | where {!@(ls -force $_.fullname)} | rm –whatif

Big fat note: Executing this on a drive will remove all files… also on the system disk if executed on that drive!!!

Post to Twitter

Posted By: Jeff Wouters
Last Edit: 23 Apr 2012 @ 06:36 AM

EmailPermalink
Tags
Categories: PowerShell, Script



Get Adobe Flash player
 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 164
  • Comments » 150
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.