Here is a script to delete old files that are 30 days or older. It used to take at least 40 lines of VBS to achieve.
Before you get too excited, a few things to be aware of:
- Availability of PowerShell: WindowsXP may not have it, and Windows 7 may only have it up to version 2. So, if you found some exciting cmdlets, chances are they are not available on your OS by default
- Executing a PowerShell file takes extra effort. It's forbidden by default. So you have to do either of the following:
- Open PowerShell, and execute this command:
- Or, when running a file use this command line (notice full path to the ps1 file has to be provided here):
PowerShell.exe -ExecutionPolicy ByPass c:\scripts\myScript.ps1
No comments:
Post a Comment