首页 > 解决方案 > 在进行过程中,您将如何在 powershell 中记录输出?

问题描述

我刚开始使用 power shell,第一个任务希望我们将所做的一切记录到日志文件中。

实验室告诉我们这样做的方式如下:

“通过执行以下命令创建文件:日期 >> LAB-winsrv.log”

“执行 ipconfig 以显示所有接口并将结果输出到日志文件”

“使用 ipconfig 恢复您在上面关闭的接口并将该命令的结果输出到日志文件”

所以基本上,它会要求您执行一个非常简单的任务,然后将结果输出添加到创建的日志文件中。但是,我很难弄清楚如何做到这一点。

标签: powershell

解决方案


The simplest way to create the log file is by reading the directions you provided: "Create a file by executing the following command: date >> LAB-winsrv.log"

The >> will create the file. I'd suggest telling it where to save the log file too, so you can find it later...

date >> C:\Temp\LAB-winsrv.log

推荐阅读