I am sure this might have been asked a million times before. I am very new to Power Shell and would like to ask if I am doing this right.
In the directory, we have many files types. What I am trying to accomplish is to move only PDF files that are older than one month. To not even touch the other file extensions. The extensions in the folder are:
pdf, xml, csv
I have searched the forums prior to asking. This is what I have so far.
get-childitem -path \\server\folder -include "*.pdf" -exclude "*.xml,*.csv" | where-object {$_.LastWriteTime -gt (get-date).AddDays(-31)} | move-item -destination \\server\folder\folder2
One question though, how would you handle an exclude if there is no file extension?
Thanks for your time and patience with this noob!