PowerShell中的输出

时间:2023-03-09 00:04:28
PowerShell中的输出

1 输出重定向

>  或者>>

2 输出控制

out-* -paging#分页输出

get-process | out-host -paging

more指令用于屏显

get-process | out-printer #发送到默认打印机,打印内容

get-process | out-printer  命令打印输出信息

利用out-file命令将信息输出到文件。

可以看出,上面的   get-process | out-file process.txt 命令确实创建了文件。

  有一点需要注意: out-file命令创建的是Unicode编码的文件,有时候为了输出ASCII编码的文件,我们需要增加-encoding参数, 从而控制输出的文本编码格式

get-process | out-file -encoding ascii -filepath .\process1.txt