Apologies if thisis abad post, if it is please redirect me...
I'm new to power shell and have a question regarding scripting an archive solution.
The solution has to do the following
Move files older than 31 days from one location to another on the same server
The solution check for a sub directory in the destination based on the date of the file being moved.
If the appropiate sub directory doesn't exist it should be created before the file is moved.
This is my crude move script that dos work but I need help with the sub directory check\creation based on the target files creation date.
get-childitem -Path "E:\PRD\ARCHIVE\" |
where-object {$_.LastWriteTime -lt (get-date).AddDays(-31)} |
move-item -destination "E:\Service Archive"
Any advice or help is much appreciated.
Alan