PowerShell输出脚本到日志文件

huangapple go评论65阅读模式
英文:

Power shell to output script to logfile

问题

$date = "12/31/2016"
Get-ChildItem T:\ -Recurse | where{$_.LastWriteTime -le [DateTime]$date}

英文:

i have this script to get all files not not accessed since 12/31/16. it runs fine, but how can i output the results to a log file ?

<pre><code>
$date = "12/31/2016"
Get-ChildItem T:\ -Recurse | where{$_.LastWriteTime -le [DateTime]$date}
</code></pre>

答案1

得分: 0

像这样,将数据传输到 Out-File 命令?

$date = "12/31/2016"

Get-ChildItem T:\ -Recurse | Where { $_.LastWriteTime -le [DateTime]$date } | Out-File oldfiles.log
英文:

Like this, piping to Out-File cmdlet?

<pre><code>
$date = "12/31/2016"

Get-ChildItem T:\ -Recurse | Where { $_.LastWriteTime -le [DateTime]$date } | Out-File oldfiles.log

</code></pre>

huangapple
  • 本文由 发表于 2023年3月7日 04:41:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75655624.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定