The following PowerShell script recipe will help you delete a remote file based on a list of computers stored in a text file. New PowerShell function will be created during the session which will be piped from the text file.
Create new file named C:\Scripts\Active_Computers.txt and populate the computer names.
function delete-remotefile {
PROCESS {
$file = "\\$_\c$\install.exe"
if (test-path $file)
{
echo "$_ install.exe exists"
Remove-Item $file -force
echo "$_ install.exe file deleted"
}
}
}
Get-Content C:\Scripts\Active_Computers.txt | delete-remotefile
That’s it.

Ram
Thanks!!! This worked out for me
Tom
Thanks Ram. How would you go about deleting specific file types. For example: I want to delete all .pst files from a list of computers.
Brian Cassidy
How could I change this script to delete a list of files (list.txt)?
Paul Edwards
Can this be used to delete PST files, if so on what OS XP and Windows 7