If you browse through a large folder structure, you may stumble across some folders that you don’t have access. It would be a lot helpful if you can do a quick scan and find all these Access Denied folders without manually go through every single of them.
Well, here is one way of doing it using the powerful PowerShell. See script as below:
$result = Get-ChildItem -Path path2scan -Recurse -ErrorAction SilentlyContinue -ErrorVariable myError Echo $myError.TargetObject
The following screenshot shows how it scans and finds out all folders in C:\Windows that I don’t have access to.
What the script does is to recursively scan the specified folder, hide and log all Access Denied errors into a variable stated with -ErrorVariable switch. And then display the error variable’s TargetObject parameter which lists all folder paths that I don’t have the right to access.
It’s a pretty nice trick that uses PowerShell to accomplish something that is very hard in Windows. Thanks to PowerShell.
Latest posts by Kent Chen (see all)
- Microsoft To-Do App Available in Preview on Windows 10, iOS and Android - April 19, 2017
- Windows 10 Tip: What’s Mini View in Movies & TV App and How To Use it - April 15, 2017
- Windows 10 Tip: How To Convert MBR Partition to GPT without Losing Data - April 12, 2017
Last updated: 03/06/2015