PowerShell - Get all Stale File Dates by UNC Recursive
- Jon Boyette
- Jan 11, 2022
- 1 min read
Save as GetNTFSPermissions.ps1, or named.ps1, when ran provide the \\computer\share and -recursive, this will step through the entire share and output the last time ALL files were accessed to C:\temp\UNCOldfiles.csv
#Enter in the path to search for.
#Using the 'Recurse' switch will search through all sub-directories as well.
$Path = Read-Host "Enter UNC path to determine stale files/folders, use -recurse to list all child items"
#Searching for directories that haven't been updated in 6 Months.
Get-ChildItem -Path $Path -Recurse -Directory | Where-Object {($_.LastWriteTime -lt (Get-Date).AddMonths(-6) )} | select FullName, LastWriteTime | Export-Csv C:\temp\UNCOldfiles.csv -NoTypeInformation
Comments