troubleshooting Question

Delete a group of files using UNC path contained with CSV file

Avatar of RandyGeorgeRedSox
RandyGeorgeRedSoxFlag for United States of America asked on
Microsoft Legacy OS
12 Comments1 Solution1949 ViewsLast Modified:
i have a large group of files that I need to delete in a wide range of locations.  I have the UNC path to all of the files I need to delete in a spreadsheet, but im having a hard time using the Remove-Item cmdlet to do the job.   I discovered the following simple script to perform this task.  

$files = Get-Content "Z:\delete\delete.csv"
foreach ($file in $files) {  
    Remove-Item -Path $file -force
write-host -foregroundcolor yellow "Delete action complete"

However, when I run the script as administrator, I get the following output.  

  + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

The files in question do exist in the specified location.  
thanks in advance for your help!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros