title: How to replace string with variable in PowerShell?
body: <p>I have this code that I am struggling a little bit with:</p>
  
  <pre><code>$NumberOfProfiles = Read-Host "Enter a number of profiles"
  $Directory = "C:\Users\Apple\Folder(1..HowMuchProfilesCreated\Text.txt"
  Variable1 = "Plane"
  Variable2 = "Yacht"
  Variable100 = "Bike"
  while ($NumberOfProfiles -gt 0) { 
  (Get-Content $Directory) | %{$_.Replace("Car", "Don'tKnowWhatToPutHere")} | Set-Content $Directory 
  $NumberOfProfiles--
  </code></pre>
  
  <p>The Text.txt file is same in all the folders and contains the same string I wish to change (e.g. "Car" in this case), but the new string should come from variables that I have declared before and(or may be it is better to use array?) </p>
  
  <p>E.g. $NumberOfProfiles = 10 and I create 10 folders where are exactly the same Text.txt and I need the "Car" to be replaced with Variable1 in folder1, Variable2 in folder2 and so on.  </p>