title: Count number of folders in directory and ignore shortcuts
body: <p>I have a script which will accurately tell me how many folders are in a directory, and the subdirectories within. However, for one directory which I am working with, there are shortcut folders which seem to cause the script to fail.</p>
  
  <p><strong>Below is the error message which I receive:</strong> </p>
  
  <pre><code>Get-ChildItem : Could not find a part of the path 'C:\Folder\SubFolder\folder1\jpos'.
  At C:\Desktop\Script Files\fileCount.ps1:34 char:10
  + $items = Get-ChildItem C:\Folder\SubFolder\ -Recurse
  +          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : ReadError: (C:\Folder\SubFolder\folder1\jpos:String) [Get-ChildItem], 
  DirectoryNotFoundException
  + FullyQualifiedErrorId : 
  DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand`
  </code></pre>
  
  <p>The script runs fine for directories without shortcuts, but it seems to always fail when there are shortcuts within the directory. </p>
  
  <p><strong>Below is the code snippet for this section:</strong></p>
  
  <pre><code>$items = Get-ChildItem C:\Folder\SubFolder -Recurse
  $termFolder = ($items | Where-Object {$_.PSIsContainer}).count
  </code></pre>
  
  <p>Is there any way to skip over shortcuts or a better way to do a folder count?</p>