Vladimir Averkin’s http://blogs.msdn.com/b/powershell/archive/2009/01/11/colorized-capture-of-console-screen-in-html-and-rtf.aspx provides the code. Here’s the core magic.
$Host.UI.RawUI.GetBufferContents(System.Management.Automation.Host.Rectangle) will return a two-dimensional character array of the contents of the buffer.
This entry cleans up the HTML function by creating XML instead of using System.Text.StringBuilder to append strings. Sadly, I don’t know RTF at all, so this is merely a merging of that code into a single function.