powershell - get-childitem 在格式之前截断名称、全名

标签 powershell buffer get-childitem truncated

<分区>

我一直在试验 get-childitem、format-table、format-string 和 out-file 的 PowerShell 组合。

无论我尝试使用 ft -wrap -autoformat 和各种其他选项,get-childitem 的调用都会将名称属性截断为总共 35 个字符(30,不包括扩展名),例如:

$dir = Get-ChildItem 'c:\mypath\*' | ft -Wrap -AutoSize -Property name

示例结果(注意:没有省略号,而是完整的扩展名):

myfilenametruncatesat30Charact.xlsx

截断 106 个字符的全名行为相同。

所以看起来 get-childitem 在通过管道传输到格式 cmdlet 之前受到某种类型的缓冲区的限制...

我看到过提到 Windows 路径的 260 个字符限制的引用资料,但这些路径的长度范围为 100 - 120。

如能提供有关 Powershell 截断原因的任何提示或线索,我们将不胜感激。

最佳答案

你可以使用

Get-ChildItem 'c:\mypath\*' | Select -ExpandProperty Name

Select-Object

-ExpandProperty

Specifies a property to select, and indicates that an attempt should be made to expand that property. Wildcards are permitted in the property name.

For example, if the specified property is an array, each value of the array is included in the output. If the property contains an object, the properties of that object are displayed in the output.

编辑

PS C:\Users\Lieven\AppData\Local\Temp> gci myfilenametruncatesat30CharactAndThenSome.xlsx | ft -Wrap -AutoSize -Property
 name

Name
----
myfilenametruncatesat30CharactAndThenSome.xlsx

关于powershell - get-childitem 在格式之前截断名称、全名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25326821/

相关文章:

function - 函数构建的搜索结果过多

powershell - 在PowerShell上按日期访问给定文件

powershell - 如何在代理后面的 Powershell 中使用 FTP 上传?

python - 每个 PowerShell 调用 Python 脚本并传递 PSObject 并返回解析的数据

azure - 使用 Powershell/Azure CLI 禁用数据中心对 Cosmos DB 的网络访问

C - 将两个结构附加到单个缓冲区

c# - NetworkStream 和 TcpClient 有多少缓冲区?

Powershell:为什么 (gci c:\ddd).count on an Empty 文件夹不返回 0

powershell - 显示如何在 Windows PowerShell 3.0 中覆盖 TabExpansion2 的示例

linux - 使用 GDB 和 Info Reg 命令不成功。似乎无法找到 ebp、eip 和 esp 值