title: How can I find the index of a String array element using the [Array]::FindIndex method in PowerShell?
body: <p>another PowerShell noob question.</p>
  
  <p>I have an array of strings that contains the names of businesses and I am writing a script that iterates through the folders of a directory and compares the folder names to the names contained in the array.  When I find a match I need to get the array index where the match was found.  I've done this successfully for exact matches using the following code:</p>
  
  <pre><code>foreach($file in Get-ChildItem $targetDirectory)
  {
      if($businesses -like "$file*")
      {
          $myIndex = [array]::IndexOf($businesses, [string]$file)
      }
  }
  </code></pre>
  
  <p>The reason I use <code>-like "$file*"</code> is because sometimes the name of the business has "LLC" or "INC" or something like that, which occasionally wasn't included when we named the folders(and vice versa).  I would like to modify my <code>$myIndex</code> line to find these indexes as well.</p>
  
  <p>I'm trying to use</p>
  
  <pre><code> $myIndex = [array]::FindIndex($Merchant, {args[0] -like "$file*"})
  </code></pre>
  
  <p>But I'm getting the error</p>
  
  <p><strong>Cannot find an overload for "FindIndex" and the argument count:  "2".</strong></p>
  
  <p>I've tried casting the second argument using <strong><code>[Predicate[string]]{args[0] -like "$file*"}</code></strong> but get the same result.  I've read the documentation for the method but one of my basic problems is I don't understand the System.Predicate type.  I'm not even sure if I'm writing it properly;  I found an example that was similar but used <code>[int]</code> instead.  Maybe I'm going about it all wrong but I feel like I'm close and just can't find the missing piece of the puzzle anywhere.</p>
  
  <p>Thanks in advance for any help.</p>