powershell - Check if folder is inactive based on last write time and read only attribute of it's files -
i trying recursively check if folder not contain files have been edited in last year. inactive in case , of it's files made read only. therefore need perform check checks if files in folder, not inactive ones, read only, because in case "been marked" , not need included in list of inactive folders.
currently have:
function folderinactive{ param([string]$path) $date = (get-date).adddays(-365) get-childitem $path -recurse -file | foreach-object { if ($_.lastwritetime -ge $date -or $_.isreadonly -eq $false) { $false } } $true }
this makes sense file last edited part, doesn't seem correct in read part. should true or false? should -or or -and? if files active, 1 of them read or not still marked inactive. doesn't seem right. can't wrap head around doing in 1 loop.
i can of course in 2 loops, dealing big file systems , therefore in 1 loop if possible.
Comments
Post a Comment