This script will scan through a list of UNC’s and it will locate any folders or files that are older than 90 days. You can change the amount of days by editing the $gtdays variable.
$servers = Get-Content "\\SERVER\" $gtdays = "90" $timeformat='yyyy/MM/dd hh:mm:ss tt' $time = (Get-Date).ToString($timeformat) $drive = "v" $drivemapped = $drive + ":" $username = 'USERNAME' $password = ConvertTo-SecureString -string 'PASSWORD' -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential -argumentlist $username, $password foreach($server in $servers) { #cmd /c net use v: $server | Out-Null New-PSDrive -name $drive -psprovider filesystem -root $server -Credential $cred | Out-Null $date = Get-ChildItem $drivemapped| Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1 $days = (New-TimeSpan $date.LastWriteTime $time).Days #cmd /c net use v: "/delete" | Out-Null Remove-PSDrive $drive | Out-Null if($days -gt $gtdays) { New-Object –TypeName PSObject -Property @{ 'Server' = $server 'File or Folder Name' = $date.Name 'Date'= $date.LastWriteTime 'Days Old'= $days } } else { } }