title: Powershell Select-String and then obtain data on returned files
body: <p>I admit I am quite tired today but even that is no excuse for the nightmare i seem to be creating for myself with Powershell at present.</p>
  
  <p>Basically the aim is to search a directory for a string that is contained in some word documents.  Then I need to return the file name, created date and the last write time.  Easy I thought but at some stage I have gone well off track and am still climbing.</p>
  
  <p>What I have done so far is run the search and export the path variable to a text file giving me the path to the files that contain the string.  I have then tried to use a foreach loop to load the contents of the file and run a Get-ChildItem against each entry piped to a Select-Object Name,CreationTime,LastWriteTime.  I have finally > this to a text file.  However it now seems to be returing the info for every file in teh directory and not just those that contain the string I am searching for.  I get the feeling I am vastly over complicating this as i tend to with these things.  Any help greatly appreciated.</p>
  
  <pre><code>Get-ChildItem -Recurse -Include *.doc | Select-String "Shiba" | select-object path &gt; C:\TRCALM\shibapath.txt
  
  
  $files = get-content C:\TRCALM\shibapath.txt
  
  
  foreach($i in $files){gci $i | select-object Name,CreationTime,LastWriteTime &gt; C:\TRCALM\SHIBADates.txt}
  </code></pre>