powershell - 为什么 -whatif 参数不传递给管道
问题描述
-Whatif
在 Powershell 脚本中使用公共参数,例如:
Remove-Item -Path "$now\$basename" -Recurse -Whatif -Force |
Write-Entry -Line $(get-linenumber) -level 'Info' |
Create-Log -title "$title.log" -display
即使我可以清楚地看到屏幕上的文本,日志文件也是空白的。我想将-Whatif
字符串传递给文本文件。我知道这与重定向有关,但据我所知。
解决方案
处理的输出-Whatif
绕过标准流进行输出,直接进入控制台。这个关于从 C#访问输出的 TechNet 问题-WhatIf
解释了。
推荐阅读
- python - 如何使用 selenium 和 python 从动态生成的页面中抓取内容?
- php - 为什么 livewire 数据绑定不起作用?
- java - 如果 bean 不存在,则禁用所需的 bean
- ag-grid - 我可以有多个具有属性 cellRenderer 的 AgGrid 列,并且每个列都显示不同的详细嵌套列吗?
- python - Django APScheduler 作业挂断而没有错误
- python-3.x - 如何解析包含 csv 文件的 Http 请求
- javascript - jquery获取数据字段
- javascript - 使用 Angular 9 和 JS 扩展表时出错(新打开的行得到以前的值)?
- flutter - 盒内颤振制作盒
- excel - 循环遍历excel vba中的列