title: Powershell script to omit traversing access denied folders from a list of folders
body: <p>I was trying to do a script to list extract the folders and subfolders and the number of files for a particular path of directory. How to exclude the folders whose access is denied in the script?  </p>
  
  <p>I used the <code>get-childitem</code> code snippet along with <code>where {$_.permission -match "read"</code>, I don't know if what I am trying is correct or not. I ended up with the following error:message:</p>
  
  <blockquote>
    <p>CategoryInfo          : ReadError: (\support....-242\New folder:String) [Get-ChildItem], IOException
        + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand</p>
  </blockquote>