Powershell script that removes files from cvs list and then exports results

This topic contains 1 reply, has 2 voices, and was last updated by  Matt Bloomfield 1 year ago.

  • Author
  • #71137


    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? I have a powershell script that removes files from a csv list. However, I'm not sure how to export the results once the files have been deleted from the list and mark them in green in a spreadsheet in Excel. How would I approach this? Below is my powershell script:

    $files = Get-Content "C:\test\remove.csv"
    foreach ($file in $files) {
    Remove-Item -Path $file -force
  • #71143

    Matt Bloomfield

    Doug Finke's ImportExcel module requires a bit of work to learn but is very powerful.

    Here's a simple example:

    $files = 'file1.exe','file2.txt','file3.pdf'
    $files | Export-Excel deletedFiles.xlsx -CellStyleSB { 
        foreach ($row in 2..$totalRows) {Set-CellStyle $workSheet $row $lastColumn Solid Green}


You must be logged in to reply to this topic.