title: Wildcard matching in Get-ChildItem in PowerShell
body: <p>Is there a way to determine how wildcard matching is done in Get-ChildItem?</p>
  
  <p>Various articles (<a href="http://msdn.microsoft.com/en-us/library/aa717088%28v=vs.85%29.aspx" rel="nofollow noreferrer">1</a>, <a href="https://stackoverflow.com/questions/10242482/powershell-filtering-for-strings#">2</a>) suggest that it is done through the <a href="http://msdn.microsoft.com/en-us/library/system.management.automation.wildcardpattern%28v=vs.85%29.aspx" rel="nofollow noreferrer">WildcardPattern class</a>, but I don’t think this is the case. For example, suppose you have a file in <code>C:\test\test2\testfile.txt</code>. Then <code>Get-ChildItem –Path “C:\*\testfile.txt”</code> will not find the file while <code>WildcardPattern::IsMatch</code> will. Wildcard <code>"*"</code> matching in Get-ChildItem seems to be on directory level: so <code>"\*\"</code> will never match more than one level, like <code>"\A\B\"</code>.</p>
  
  <p>So if <a href="http://msdn.microsoft.com/en-us/library/system.management.automation.wildcardpattern%28v=vs.85%29.aspx" rel="nofollow noreferrer">WildcardPattern class</a> isn't used, then what is?</p>