Server_Name Process_Name Server_Status Process_Available
----------- ------------ ------------- -----------------
FILESTORAGE1 notepad Online No
FILESTORAGE1 explorer Online Yes
FILESTORAGE1 Sampler Online No
FILESTORAGE1 notepad Online No
FILESTORAGE1 explorer Online Yes
FILESTORAGE1 Sampler Online Yes
FILESTORAGE1 notepad Offline No
FILESTORAGE1 explorer Offline No
FILESTORAGE1 Sampler Offline No
我的文件看起来像这样。
我想从我的文件中获取每个元素并创建一个HTML文件(来自此TXT)
$bodyFromFile = Get-Content "$PSScriptRoot\data.txt"
$bodyString = $bodyFromFile | ConvertTo-Html
不幸的是,bodyString的内容看起来像是合法的HTML。文件中的数据不在变量中。
答案 0 :(得分:1)
如果希望最终结果是表格HTML输出,请不要将对象转换为字符串。而不是
... | Out-String | Out-File "$PSScriptRoot\data.txt"
$bodyFromFile = Get-Content "$PSScriptRoot\data.txt"
$bodyString = $bodyFromFile | ConvertTo-Html
做这样的事情:
$table = ... | ConvertTo-Html -Fragment
$bodyString = "<body>$table</body>"