尾随空间

时间:2011-03-14 13:48:14

标签: powershell spaces file-io

当我运行以下命令时,会导致每个对象后面都有尾随空格。我删除它们的最佳方法是什么?

Get-VMHost |选择名称| out-file c:\ temp \ hosts.txt

2 个答案:

答案 0 :(得分:2)

所以你真的需要单个属性的表视图吗?请记住,表和列表输出应该由人类读取,而不是通过管道传输到文件中。

您可以使用

Get-VMHost | Select -Expand Name | Out-File hosts.txt

只输出名称。

答案 1 :(得分:0)

使用Set-Content(和/或Add-Content)没有格式化工件。

相关问题