Quantcast
Viewing all articles
Browse latest Browse all 21975

Remove folders and contents after X days from an external drive root

Hi all second post, similar subject... Go easy please !

As per my previous post which was answered by @mjolinor

The code I had worked fine when the files and folders where already contained in a folder. Now I need them to run from the root of an external drive.

Code that works:

get-childitem "G:\TEST\" -Exclude VERITAS, TEMP |
? {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(-7)} |
% {remove-item $_ -force -recurse -whatif}

Code that doesn't:

get-childitem "G:\" -Exclude VERITAS, TEMP |
? {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(-7)} |
% {remove-item $_ -force -recurse -whatif}

Any help would be appreciated.

Thank you.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>