# This script lists all files that haven't been modified within three years.
# Get the current date and time.
$currentDateTime = Get-Date
# Calculate the date three years ago.
$threeYearsAgo = $currentDateTime - (3 * (365.25 * 24 * 60 * 60))
# Find all files that have not been modified since three years ago.
$files = Get-ChildItem -Recurse -ErrorAction SilentlyContinue | Where-Object {
# Get the last modified date of the file.
$lastModifiedDateTime = $_.LastWriteTime
# Compare the last modified date to the date three years ago.
$lastModifiedDateTime -lt $threeYearsAgo
}
# Print the list of files.
ForEach ($file in $files) {
Write-Host $file.FullName
}