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的内容看起来是合法的。文件中的数据不在变量中。
发布于 2015-09-09 14:17:06
当您希望最终结果是表格式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>"https://stackoverflow.com/questions/32479931
复制相似问题