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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,462 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MotoX80 32,911 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