title: Parsing html tag link with Powershell
body: <p>I want to copy the content of the first tag (the link) to the next 2 tags:</p>
  <pre><code>&lt;link rel=&quot;canonical&quot; href=&quot;https://website.com/en/america.html&quot; /&gt;
  </code></pre>
  <p>to</p>
  <pre><code>&lt;meta property=&quot;og:url&quot; content=&quot;https:/something-better/rosrr.html&quot;/&gt;
  
  &quot;@id&quot;: &quot;https://distrinct.com/stiintess-pomei.html&quot;
  </code></pre>
  <p><strong>Output:</strong></p>
  <pre><code>&lt;link rel=&quot;canonical&quot; href=&quot;https://website.com/en/america.html&quot; /&gt;
  
  &lt;meta property=&quot;og:url&quot; content=&quot;https://website.com/en/america.html&quot;/&gt;
  
  &quot;@id&quot;: &quot;https://website.com/en/america.html&quot;
  </code></pre>
  <p><strong>I really don't know why my Powershell code is not working as I want:</strong></p>
  <pre><code>$sourcedir = &quot;C:\Folder1\&quot;
  $resultsdir = &quot;C:\Folder1\&quot;
  
  Get-ChildItem -Path $sourcedir -Filter *.html | ForEach-Object {
      $content = Get-Content -Path $_.FullName -Raw
      $replaceValue = (Select-String -InputObject $content -Pattern '(?&lt;=&lt;link rel=&quot;canonical&quot; href=&quot;).+(?=&quot; /&gt;)').Matches.Value
      $content = $content -replace '(&lt;meta property=&quot;og:url&quot; content=&quot;).+(&quot;/&gt;)',$replaceValue
      $content = $content -replace '(&quot;@id&quot;: &quot;).+(&quot;)',$replaceValue
      Set-Content -Path $resultsdir\$($_.name) $content
  }
  </code></pre>
  <p><strong>This is what I get, instead of the Output I want:</strong></p>
  <p><a href="https://i.stack.imgur.com/zzkLD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zzkLD.png" alt="I get" /></a></p>