我正在寻找一种简洁的方法来呈现PowerShell中HTML字符串的显示,而不使用MSIE或将结果写入文件。
有没有办法在XAML中使用WebBrowser来实现这一点?
当我尝试这样做时,WebBrowser似乎没有DocumentText或Document.Text成员设置为所需的文本。
您可以指定一个源,所以我尝试了将数据URL作为源,但是WebBrowser似乎不支持将数据URL作为源。
如果HTML能够以某种方式内联在XAML中,或者作为文档文本的属性发送到浏览器,那就太好了。
- 我不想写文件。我知道怎么做,但认为这是不好的做法。
- 我不想依赖MSIE,因为MS放弃了t,并且不再推荐使用它。如果代码很少,我不介意使用Add-Type调用VB或C#之类的东西。
- 我不想下载任何特殊的软件。我想知道如何用PowerShell来做这件事。这看起来很简单,你会认为会有一个内置的Show-HTML Cmdlet来做这件事,就像ogv一样简单。(毕竟,有很多命令可以转换成html或将html生成为字符串)
几年前,这里有一个关于堆栈溢出的类似问题的答案,建议将MSIE作为答案,但现在MSIE已被弃用,不再是一个选项。PS、XAML和.net自那时以来肯定有所进步。
1条答案
按热度按时间gupuwyp21#
您可以简单地将XAML嵌入到PowerShell中,然后从那里开始。
(动态)PowerShell BGInfo示例:
用途
要进行故障排除和调试,请使用以下命令: