【发布时间】:2022-11-19 14:00:50
【问题描述】:
管道中的下一个命令如何识别我的输出对象属性名称?
PowerShell 控制台将自动完成属性名称,这非常有帮助。仅输入“fulln”并按 TAB 将生成“FullName”。
Get-ChildItem | Select-Object -Property fulln<TAB>
我编写的脚本生成 System.IO.FileInfo 对象。
PS C:\> (Find-MyFile -Files @('whatiwant.txt','whatelseiwant.txt')[0].GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False FileInfo System.IO.FileSystemInfo
但是,对于后续的 Select-Object 命令,FileInfo 属性的自动完成并未完成。
PS C:\> (Find-MyFile -Files @('whatiwant.txt','whatelseiwant.txt') | Select-Object -Property lastw<TAB>
我需要做什么才能自动完成?这是否需要创建用于格式化的 .xml 文件?
【问题讨论】:
标签: powershell