Disclaimer
This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

Delete multiple files or folders input from a CSV file (Powershell)

*** THIS SCRIPT IS PROVIDED WITHOUT WARRANTY, USE AT YOUR OWN RISK ***
This script will delete one or more files or folders based on input of a list from a CSV file. I wrote this to work in conjunction with this script: https://www.signalwarrant.com/2013/04/20/search-file-structure-for-a-file-or-file-type-and-put-the-results-in-a-csv-file-powershell/.

Pretty simple but very effective.

 

 

3 Comments

  1. Joe Shmoe | | Reply

    Thank you for the script that you have provided. How do I export the results into an Excel spreadsheet and highlight them in green once the files have been deleted from a csv list in PowerShell?

  2. Joe Shmoe | | Reply

    How do I export the results into an Excel spreadsheet and highlight them in green once the files have been deleted from a csv list in Powershell?

    • Greg | | Reply

      Joe,

      I expect you’ve found your answer to this question, or moved on by now. But if others have the same question, here are a couple possible solutions.

      You’d have to format the text after you exported it, since CSV doesn’t support colored text as far as I know. To create the CSV from your results, you could pipe the last command to a CSV file, or use PowerShell’s Tee object to direct the output to a CSV and elsewhere: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-5.1.

      -Greg

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.