script deletion

Hi Experts,

I would like to automate the cleanup of all log files in the following path for a farm of Exchange servers

C:\Program Files\Microsoft\Exchange Server\V15\Logging\Diagnostics\DailyPerformanceLogs
C:\Program Files\Microsoft\Exchange Server\V15\Logging\Monitoring\Monitoring\MSExchangeHMWorker\ActiveMonitoringTraceLogs
C:\Program Files\Microsoft\Exchange Server\V15\Logging\MonitoringLogs\STx
C:\Program Files\Microsoft\Exchange Server\V15\Logging\RpcHttp\W3SVC2
C:\Program Files\Microsoft\Exchange Server\V15\Logging\RPC Client Access



I would like to delete all log files on each path above, for a farm of Exchange servers. These servers will be declared on a TXT or CSV file, whatever works [and the csv file only contain FQDN of each server], and the script will check this input file

Can someone please help me to build this script?

Btw, the script will delete any file with size greater than 0 KB, and this condition is a must, because a file with size equal to zero means that is being used by the OS and cannot be deleted
Jerry SeinfieldAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

QPRCommented:
There is a script at the Microsoft gallery for just this thing.
There is a parameter which you can use to specify how old the logs should be before being considered ready for deletion.. this should cover you when worrying about any files still in use by the OS.
Will this work?
https://gallery.technet.microsoft.com/office/Purge-Exchange-Server-2013-c2e03e72

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jerry SeinfieldAuthor Commented:
thanks,

can someone else write a simple script to purge the log files only for the locations above?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.