![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | deleting files using a date criteria Hello: how do I delete all files that are 6 months older in a directory of a local or remote server using powershell script? Any help would be appreciated! Thanks! WG |
My System Specs![]() |
| | #2 (permalink) |
| | Re: deleting files using a date criteria get-childitem $RemoteShare | where{!$_.PSisContainer -and $_.LastWriteTime -gt (get-date).addmonths(-6)} Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject W> Hello: W> W> how do I delete all files that are 6 months older in a directory of a W> local or remote server using powershell script? Any help would be W> appreciated! W> W> Thanks! W> W> WG W> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: deleting files using a date criteria oh.. add -recurse if you want to recurse subfolders as well. get-childitem $RemoteShare -recurse ... Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject BS> get-childitem $RemoteShare | where{!$_.PSisContainer -and BS> $_.LastWriteTime -gt (get-date).addmonths(-6)} BS> BS> Brandon Shell BS> --------------- BS> Blog: http://www.bsonposh.com/ BS> PSH Scripts Project: www.codeplex.com/psobject W>> Hello: W>> W>> how do I delete all files that are 6 months older in a directory of W>> a local or remote server using powershell script? Any help would be W>> appreciated! W>> W>> Thanks! W>> W>> WG W>> |
My System Specs![]() |
| | #4 (permalink) |
| | Re: deleting files using a date criteria On Oct 22, 2:26 pm, Brandon Shell [MVP] <a_bshell.m...@xxxxxx> wrote: Quote: > get-childitem $RemoteShare | where{!$_.PSisContainer -and $_.LastWriteTime > -gt (get-date).addmonths(-6)} > > Brandon Shell > --------------- > Blog:http://www.bsonposh.com/ > PSH Scripts Project: www.codeplex.com/psobject > > W> Hello: > W> > W> how do I delete all files that are 6 months older in a directory of a > W> local or remote server using powershell script? Any help would be > W> appreciated! > W> > W> Thanks! > W> > W> WG > W> your current code gets all items *modified in the last 6 months*, not files older than 6 months. - Oisin |
My System Specs![]() |
| | #5 (permalink) |
| | Re: deleting files using a date criteria Details... Details... ![]() Thanks for the catch Oisin, This is exactly why I do not ever add the remove-item at the end ![]() Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject OG> On Oct 22, 2:26 pm, Brandon Shell [MVP] <a_bshell.m...@xxxxxx> OG> wrote: OG> Quote: Quote: >> get-childitem $RemoteShare | where{!$_.PSisContainer -and >> $_.LastWriteTime -gt (get-date).addmonths(-6)} >> >> Brandon Shell >> --------------- >> Blog:http://www.bsonposh.com/ >> PSH Scripts Project: www.codeplex.com/psobject >> W> Hello: >> W> >> W> how do I delete all files that are 6 months older in a directory >> of a >> W> local or remote server using powershell script? Any help would be >> W> appreciated! >> W> >> W> Thanks! >> W> >> W> WG >> W> OG> OG> your current code gets all items *modified in the last 6 months*, OG> not files older than 6 months. OG> OG> - Oisin OG> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Date Type mismatch in criteria expression | VB Script | |||
| Possible to Read only Selected lines from multiple files into anotherfile deleting source files when processed? | PowerShell | |||
| deleting files that meet specific criteria | PowerShell | |||
| WMP deleting metadata by itself: album, genre, date... | Vista music pictures video | |||
| last access date for files | PowerShell | |||