如何更好地格式化输出?

时间:2019-02-25 23:31:27

标签: powershell

假设我有以下输出,一直从循环输出:

Write-Host "`r`n $server | $db | success! | [$Time] "

我得到的当前输出是这样的:

output

有没有办法让我等价地格式化?

这样它最终会像这样:

proper_output

1 个答案:

答案 0 :(得分:1)

感谢@Lee_Dailey,我能够获取格式!

我使用了-f运算符:

"`r`n {0,1} | {1,-32} | {2,-20} | {3,1} " -f "$server","$db","success!","[$Time]"

https://ss64.com/ps/syntax-f-operator.html