powershell - 在进行过程中,您将如何在 powershell 中记录输出?
问题描述
我刚开始使用 power shell,第一个任务希望我们将所做的一切记录到日志文件中。
实验室告诉我们这样做的方式如下:
“通过执行以下命令创建文件:日期 >> LAB-winsrv.log”
“执行 ipconfig 以显示所有接口并将结果输出到日志文件”
“使用 ipconfig 恢复您在上面关闭的接口并将该命令的结果输出到日志文件”
所以基本上,它会要求您执行一个非常简单的任务,然后将结果输出添加到创建的日志文件中。但是,我很难弄清楚如何做到这一点。
解决方案
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
推荐阅读
- c# - 如何在部分类中实现 OnPropertyChanged 事件
- git - SourceTree - 反向提交和推送
- javascript - Javascript onchange 功能在移动设备上的选择菜单中不起作用
- android - android 应用程序消息中的本地化问题在 RTL 中反向显示
- nginx - 如何重定向到外部 https 站点?
- jenkins - 使用 Jenkins 向 JBoss 部署战争时“无法初始化命令上下文”
- microsoft-graph-api - Microsoft Graph:获取用户时区
- swift - Swift Generics - 尝试使用专用子协议作为变量时,尝试使通用协议具体化失败
- ruby - 在 ruby 中使用 OpenSSL 解密 aes-128-gcm tls 包时的一个非常奇怪的现象
- swift - 同步调度的保留计数如何工作?