title: PowerShell: How can I list the index of an item using format-table?
body: <p>I wish to list the index of an item in a result table.</p>
  
  <p>In this case I am using get-aduser with the filter option.</p>
  
  <p>I am then using format-table with -Property to display only the properties I want.</p>
  
  <p>I previously used a loop to display the items along with a counter to emulate the index but this was messy and I wanted it in a table.</p>
  
  <p>Code:</p>
  
  <pre><code>$search_param = read-host "Enter search string: "
  $search_param = "*" + $search_param + "*" # Construct search param.
  $search_result = Get-ADUser -Filter {Surname -like $search_param -or GivenName -like $search_param -or SamAccountName -like $search_param}
  
  
  $search_result | format-table -Property GivenName,Surname,SamAccountName
  </code></pre>
  
  <p>How can I get format-table to display the item index/position without using some kind of loop? ie, is there some kind of 'hidden' index property that I can simply provide to format-table?</p>