Windows Tip Sheet
Clean Up Your Room
Two-steps to sanity ... er ... a cleaner server.
How often did your mom tell you to pick up after yourself? It's something
you probably tell your users as well. It's a sad fact, but occasionally
you need to do some housecleaning. Depending on your applications, you
may find all sort of backup and temp files that simply need to be cleaned
out. Here's an easy, two-step process.
Tech HelpJust An
Got a Windows, Exchange or virtualization question
or need troubleshooting help? Or maybe you want a better
explanation than provided in the manuals? Describe
your dilemma in an e-mail to the MCPmag.com editors
the best questions get answered in this column and garner
the questioner with a nifty Redmond T-shirt.
When you send your questions, please include your
full first and last name, location, certifications (if
any) with your message. (If you prefer to remain anonymous,
specify this in your message, but submit the requested
information for verification purposes.)
First, we'll use the FOR command to create a text file
FOR /f %x in ("~*.*,*.bak,*.tmp,*.dmp") do @DIR
E:\Files\%x /s /b >>deleteme.txt
In parentheses and quotes, add all the file extensions you want to find
separated by commas. Change the DIR path accordingly. This command will
recurse from this directory and record the full path of every file found
in the deleteme.txt file. The command will append to deleteme.txt if it
already exists, so delete the file before running the command again or
use a different file name.
When the command finishes, review deleteme.txt to make sure there's nothing
you want to keep. Edit the file as needed. To delete all the files, simply
FOR /f "tokens=*" %x in (deleteme.txt) do @DEL
In no time at all you've have your server cleaned up and you'll be able
to go out and play.
I'll come back to these techniques in another column and exploit them
Jeffery Hicks is a Microsoft MVP in Windows PowerShell, Microsoft Certified Trainer and an IT veteran with over 20 years of experience, much of it spent as an IT consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He works today as an independent author, trainer and consultant. Jeff writes the popular Prof. PowerShell column for MPCMag.com and is a regular contributor to the Petri IT Knowledgebase and 4SysOps. If he isn't writing, then he's most likely recording training videos for companies like TrainSignal or hanging out in the forums at PowerShell.org.
Jeff's latest books are Learn PowerShell 3 in a Month of Lunches, Learn PowerShell Toolmaking in a Month of Lunches and PowerShell in Depth: An Administrators Guide.
You can keep up with Jeff at his blog http://jdhitsolutions.com/blog, on Twitter at twitter.com/jeffhicks and on Google Plus (http:/gplus.to/JeffHicks)