Script to delete files created on a specific date with sepecific name


hi,

is possible me powershell script delete files under folder , subfolders have following attributes

1. have name (default.*) , (index.*)

2. created on specific date 1-9-2014

3. created between specific time between 10:00 - 16:00

thanks in advance!

hi,

try this:

$path=$env:userprofile $startdate=[datetime]::parseexact("01-09-2014 10:00","dd-mm-yyyy hh:mm",$null) $enddate=[datetime]::parseexact("01-09-2014 16:00","dd-mm-yyyy hh:mm",$null)  #ps3 version get-childitem -file -path $path -include "default.*","index.*" -recurse | {$_.creationtime -gt $startdate -and $_.creationtime -lt $enddate}| remove-item -whatif #ps2 version get-childitem -path $path -include "default.*","index.*" -recurse | {$_.creationtime -gt $startdate -and $_.creationtime -lt $enddate -and !$_.psiscontainer} | remove-item -whatif

luck)





Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607