[英]PowerShell Get-ChildItem full path is truncated
I'm capturing the file full path and last modified date in a text file but few directories with longer path gets truncated. 我正在捕获文本文件中的文件完整路径和上次修改日期,但是路径较长的目录却被截断了。 Is it possible to get the full path without truncation or
...
. 是否有可能获得完整的路径而不会被截断或
...
Code I used: 我使用的代码:
Get-ChildItem -Path "\\server\xyz_data\devdata\fail logs\xxx\yyy\2012\01june2012\" -Recurse |
select -Property Filename, LastWriteTime |
Out-File -Encoding Ascii -Append d:/file.txt
Output: 输出:
server\xyz_data\devdata\fail logs\xxx\yyy\2012\01june2012\text123..... 22/03/2012 11.23.00
Is there any restrictions on number of characters to captured? 捕获的字符数是否有限制?
Actually, because of the spaces in between the parameters like - recurse
, and the missing hyphen in the Out-File
cmdlet, your code should not run at all.. Also, I think you mean FullName
instead of filename
. 实际上,由于参数
- recurse
和Out-File
cmdlet中缺少连字符之间存在空格,因此您的代码根本不应该运行。此外,我认为您的意思是FullName
而不是filename
。
Try 尝试
Get-childitem -Path "\\server\xyz_data\devdata\fail logs\xxx\yyy\2012\01june2012\" -Recurse |
Select-Object -Property FullName, LastWriteTime |
Export-Csv -Path 'd:/file.csv' -Force -NoTypeInformation
PS I used Export-Csv
to output the results to file PS我使用
Export-Csv
将结果输出到文件
I assume it's fullname, not filename. 我认为它是全名,而不是文件名。 It seems like out-file pipes it through format-table first, and depending on the width of your window will truncate the filename.
似乎文件外首先将其通过格式表进行管道传输,然后根据窗口的宽度截断文件名。 Out-file also encodes in unicode.
外文件也以unicode编码。 Export-csv is the way to go.
Export-csv是必经之路。 Interestingly, piping to set-content instead would save it as hashtables.
有趣的是,管道传递给set-content会将其另存为哈希表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.