更新时间:2023-12-03 19:16:22
尝试以下方法:
($OSInfo `
| Format-List `
@{Name="OS Name";Expression={$_.Caption}},
@{Name="OS Boot Time";Expression={$_.ConvertToDateTime($_.LastBootUpTime)}},
@{Name="OS Install Date";Expression={$_.ConvertToDateTime($_.InstallDate)}} `
| Out-String).Trim()
这将清除Format-List
产生的所有多余的空白行.您可能需要插入一些自己要控制的东西.
That'll clean up all the extraneous blank lines produced by Format-List
. You may need to insert a couple of your own that you get to control.