Powershell script to delete the "oldest" file.
i have scripts prune operating logs date, in case need delete 1 file among group. doesn't matter one, 1 of files. paint picture, use files on shared volume artifically fill volume. space presented our san , when our users run out of space remove 1 of these large files stop denial of service due disk space. want create powershell script remove "one" of files elleviate disk space issue.
any thoughts? in advance!
try this:
get-childitem m:\ | sort creationtime | select -first 1 | remove-item
gets list of items, sorts them creation date, grabs last 1 in list (oldest) , deletes item.
rich prescott | infrastructure architect, windows engineer , powershell blogger | mcitp, mcts, mcp
engineering efficiency
@rich_prescott
client system administration tool
ad user creation tool
Windows Server > Windows PowerShell
Comments
Post a Comment