title: Changing a binary registry value with PowerShell from a .reg file
body: <p>I have exported a registry directory that I would like to use in a PowerShell script. The .reg file contains two very long hex strings that I have been trying to use in <code>Set-ItemProperty</code> and <code>New-ItemProperty</code>, but neither have been successful. I keep getting errors whenever I run my script because PowerShell seems to have problems with the 'cc' hex values.</p>
  
  <p>Things I have tried:</p>
  
  <ul>
  <li><p>Assigning the hex values to a variable and using that in <code>Set-ItemProperty</code> and <code>New-ItemProperty</code></p>
  
  <pre><code>New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -Name "Favorites" -PropertyType BINARY -Value $favorites
  </code></pre></li>
  <li><p>Putting the hex values directly into the cmdlet with no formatting</p></li>
  <li><p>Putting the hex value into the cmdlet with double and single quotes around them</p></li>
  <li><p>Removing the old keys and creating new ones with<code>-PropertyType Binary</code></p></li>
  </ul>
  
  <p>Reg file: <a href="https://pastebin.com/rrAzMivQ" rel="nofollow noreferrer">https://pastebin.com/rrAzMivQ</a><br>
  PS script: <a href="https://pastebin.com/NrQFr71w" rel="nofollow noreferrer">https://pastebin.com/NrQFr71w</a>  </p>