title: select-string use in a for-each loop
body: <p>I am working on building a script that will access a large amount of files and pull a specific string out in order to assign as a variable.</p>
  <p>The string is similar across all files which is not the issue. I am able to make this process function as an individual event (define a single source file)</p>
  <pre><code>$hostname_import = select-string .\test.txt -Pattern 'hostname ABC-.+'
  $hostname = $hostname_import -replace '.+ ',''
  </code></pre>
  <p>The above would output the specific hostname identified in the target file (the second function is to trim the word hostname and the space) I can then use this to proceed with using the variable as needed to perform various actions.</p>
  <p>The issue I am having is executing this function in a foreach loop so that I can grab the initial file- execute the select-string function (or similar) and then perform the data modification within the loop as expected.</p>
  <p>For context- I am going through configuration files- and building a separate file based on those configurations to report on findings- part of the report building requires the hostname of the device.</p>
  <p>--<strong>EDIT 1:</strong>
  After consulting with my rubber duck I will be attempting to import these files as CSVs in order to potentially reach a solution.</p>
  <ul>
  <li>Thanks @Otter for getting me through that. I had a previous script that used this function but for whatever reason I couldn't execute the function as anticipated. The difference between my previous script and this one was the $_.Fullname</li>
  </ul>
  <p>Huge help!</p>