Searching and Deleting
I need help to deploy something, it could be a batch file or even a vbscript. I need this to run on servers and search for a file on all drivessince most servers have multiple drive configuration. Once the file is found, I need it to be deleted. I know this is possible I just dont know exactly how to get start with this or get it done. I have tried doing it with a batch file which inside I stated a command which is( Del filename.exe /s append d: )Now this line of code what it does it actually find the file in the c drive and deleted but when it gets to the d drive and wipes everything out of there, I believe is becuase the append line of code is being passed but without the filename.exe condition. I would appreciate any help. Gabriel
December 18th, 2008 7:35pm
Well you can use this if the server has all local drives. If you are run SAN connected LUNs, mount points, etc.. then the script would need to be modified to do a WMI query on volume names.This powershell script will allow you to search all local drives for a single file and delete that file. If you have a more specific function like multiple files or folders I can help with that. This would require powershell installed on each server. You could even streamline this more and run it from a central location that hit a whole list of servers at one time.$drives = get-psprovider filesystemforeach ($drive in $drives){get-childitem -include <filename> -recurse -path $drive.root| remove-item}Sr. Exchange Engineer - Constellation Energy
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2008 9:18pm
Thanks Aaron I appreciate it, Well the servers that I want to run this are not connected at all to any san. They only have local drives, which basically are c, d. I would like to deploy the script or batch file to the server to search and delete on both these drives. The file that Im looking for is only one file, if need later I will remodify the script and configure for a different name as for now , its only one file. I wouldnt mind installing powershell on these servers but I was wondering if I could do it without it right now since its a numerous amount of servers, The command stated above, is that powershell itself, how do I run, or create it, is like a batch file, or vbscript creation. Gabriel
December 18th, 2008 10:05pm
Yes that is a powershell script that you would place in notepad or a script editor and save as a .ps1 file. I can do it in vbscript but it will take me a bit more time because I have to do recusive loops to crawl all directories and do an inspection of file names to compare. If you would like I can make you one but it may not be until Monday.Sr. Exchange Engineer - Constellation Energy
Free Windows Admin Tool Kit Click here and download it now
December 19th, 2008 12:32am
Sounds great. If its not a problem I can wait till for you to create it, I will keep trying to create one as well. It really doesnt have to be to complicated. I understand that whats causing to be complicated is that it has to go through every drive and actually know that theredifferent drives on the computer. Thanks in advance. This is something really needed, Gabriel
December 19th, 2008 1:35am