title: How to set a binary registry value (REG_BINARY) with PowerShell?
body: <p>How to set a binary registry value (REG_BINARY) with PowerShell?</p>
  
  <p><em>Background:</em></p>
  
  <p>I need to change some properties of the ASP.NET State service using a PowerShell script. Unfortunately, the built-in PowerShell cmdlet <code>Set-Service</code> only lets you modify the service description, startup type, display name, and status. I need to modify the <code>Subsequent failures</code> property found on the Recovery tab (when viewing the service's properties). I found that this value was stored in the registry as a REG_BINARY value. </p>
  
  <p>An export of the value looks like this:</p>
  
  <pre><code>[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\aspnet_state]
  "FailureActions"=hex:50,33,01,00,00,00,00,00,00,00,00,00,03,00,00,00,0e,00,00,\
    00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00,01,00,00,00,00,00,00,00
  </code></pre>
  
  <p>In Powershell there is a <code>Set-ItemProperty</code> cmdlet with which you can set registry value values. For a string or dword value, you can just pass a string or an int. I know which hex value in the array to change, but I can't figure out how to set a binary value.</p>