如下所示,将提取文件夹中所有.msg文件的内容。但是,我只能在输出content.txt中看到1个.msg内容,而不是所有.msg文件。如何循环命令并添加到相同的.txt文件?
$output_file3 = ‘c:\outlook_files\content.txt’
# Search messages
Get-ChildItem "c:\outlook_files\msg\" -Filter *.msg | Foreach-Object {
# Read current message content
$content = Get-Content $_.FullName >$output_file3
}
代替使用重定向,使用Out-File -append
或Add-Content
所以改变
$content = Get-Content $_.FullName >$output_file3
至
Get-Content $_.FullName | out-file $output_file3 -append
我删除了变量赋值,因为在这种情况下它什么也不做。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句