Powershell script pull files dated earlier 2017

2021-08-30T11:56:51.79+00:00

I need to create a powershell script to pull files and folders dated earlier than 2017, windows server 2019

Location: C:\stofs01

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 36,406 Reputation points
    2021-08-30T12:46:25.45+00:00

    File and folders have 3 date properties. CreationTime, LastWriteTime, LastAccessTime

    Here's an example using LastWriteTime.

    $targetDate = get-date -Year 2017 -Month 7 -day 1
    get-childitem -path c:\temp -recurse | Where-Object {$_.LastWriteTime -lt $targetDate}
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.