title: Can I do this in powershell? Read the Registry, write out binary contents to file
body: <p>This is the C# code.  Can you help me translate this to powershell? </p>
  
  <pre><code>private static void Main(string[] args)
  {
      byte[] buffer = (byte[]) Registry.LocalMachine.OpenSubKey(@"HARDWARE\ACPI\DSDT\HP____\8510x\00010000").GetValue("00000000");
      if (File.Exists("8510x.orig"))
      {
          Console.WriteLine("File 8510x.orig already exists.");
      }
      else
      {
          using (FileStream stream = new FileStream("8510x.orig", FileMode.CreateNew))
          {
              stream.Write(buffer, 0, buffer.Length);
              stream.Flush();
              stream.Close();
          }
          Console.WriteLine("Wrote 8510x.orig.");
      }
  }
  </code></pre>