in Windows 2008 R2, I have a shared folder structure like this
D:\USERS
D:\USERS\USER1
D:\USERS\USER1\AUTOBACKUP
D:\USERS\USER1\DROP
D:\USERS\USER1\EXHIBIT
D:\USERS\USER2
D:\USERS\USER2\AUTOBACKUP
D:\USERS\USER2\DROP
D:\USERS\USER2\EXHIBIT
There are are 100 users folders and all users copy there important data in there AUTOBACKUP folder. Every AUTOBACKUP folder have several sub folders and files in it.
My requirements is to display ONLY the AUTOBACKUP folders name who are not updated in last 1 month, means no file in written in any autobackup or in its subfolders. (I dont requires drop/exhibit folders details as it can be updated by any1 , but autobackup can be updated only by the corresponding user)
Result Something like:
D:\USERS\USER1\AUTOBACKUP - Updated
D:\USERS\USER2\AUTOBACKUP - ALERT: Not updated since last month ...
or show me result only for users whose auto backup have not updated from past month.
I tried to get result by powershell commands, but it shows me results if some one update the drop/exhibit too, and i want to exclude them in search criteria, the search should be done only in autobackup.
UPDATED: Ok I am trying following script, but getting hit by long path error. the folders are deep, means autobackup folders have several sub folders inside it with long file names too, therefore getting error. howto overcome this issue now :(
$users = Get-Content C:\myusers.txt
$lastMonth = (Get-Date).AddMonths(-1)
$backupfiles = Get-ChildItem $path -Recurse
$logLocation = "D:\mylog.log"
foreach ($user in $users){
$path = "D:\Users\$user\AUTOBACKUP"
$backupfiles = Get-ChildItem $path -Recurse
foreach ($file in $backupfiles){
$modifiedDate = $file.LastWriteTime
if ($modifiedDate -ge $lastMonth){
$nobackup = $false
break
} else {
$nobackup = $true
}
}
if ($nobackup){
Add-Content -Path $logLocation -Value "$filepath - NOBACKUP"
}
}
Get-ChildItem -Path \\?\d:
ORGet-ChildItem -Path \\?\d:\temp
ORGet-ChildItem -Path \\?\d:
OR "\\?\$path"$backupfiles = ([IO.DirectoryInfo]"\\?\$path").GetFiles('*', [IO.SearchOption]::AllDirectories)