Posted On March 31, 2019

PowerShell Script to Clean Up Files Older than X Days

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell Script to Clean Up Files Older than X Days
$purgePeriod = 30;

$folders = '\\FILSERVER01\ORDERS\BACKUP','C:\SFTP_BACKUP';

Get-ChildItem -path $folders | where {$_.Lastwritetime -lt (date).adddays(-$purgePeriod)} | remove-item;

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Get IP’s From Computer Names

Resolve from Names to IPs: $names=@( 'TESTVM001', 'TESTVM002', 'TESTVM003' ) foreach($name in $names){ $ips =…

PowerShell: Reset Windows 10 to Default Factory Settings

The easiest (GUI) method: systemreset -cleanpc The automated method: # Experimental code: not working yet…

PowerShell: Creating Clustered File Shares

# Define Destination Mount Points and UNC Paths $arr=@{} $arr["from"] = @{}; $arr["to"] = @{}…
Other project: DragonCoin.com