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.