I’m needing to conduct a search of a user’s network drive, identifying all of the files that are older than X days. While writing a simple get-ItemChild script that will dive through a Recurse search of the drive I’m encountering folders that my administrative account doesn’t have access to. These network drives are decades old, and the organization of the drive and permissions is a mess. I’d like to capture a list of the folders that I don’t have access to, so that we can then go through and correct the permissions on the folder. The error is occurring at the time of the recursive gathering of the folders.
Is there a way to grab the name of the folder that I’m encountering access issues?
At C:\Temp\OldFiles.ps1:34 char:12 + $folders = get-childitem $dir -Directory -Force -Recurse + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ReadError: (\\fileserver\user_sata\UserName\Favorites:String) [Get-ChildItem], IOException + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand