【问题标题】:No Output Powershell Script没有输出 Powershell 脚本
【发布时间】:2013-09-16 23:05:38
【问题描述】:

当我运行这个脚本时,它没有输出。我认为这很明显,但尽管它创建了 test.txt,但它删除的文件中没有数据放入其中!

提前致谢

$limit = (Get-Date).AddDays(-7) 
Get-ChildItem 'C:\temp' -Recurse | 
Where-Object {
 -not $_.PSIsContainer -and $_.CreationTime -lt $limit 
} |  Remove-Item | Out-File -FilePath c:\text.txt

【问题讨论】:

    标签: powershell powershell-3.0


    【解决方案1】:

    Remove-Item 没有输出。您可以从 Remove-Item 启用详细输出,然后将 Verbose 流重定向到标准输出流,如下所示:

    ... | Remove-Item -Verbose 4>&1 > c:\text.txt
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-01
      • 2018-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多