我遇到了cmdlet -expand
参数的问题select-object
.我从帮助文件中了解到,我可以select-object
输出扩展属性和其他属性,但这似乎不适用于我的情况.
根据帮助文件中的示例,以下工作:
PS> Get-Process | select-object Name -expand Modules | fl
Name : chrome
ModuleName : chrome.exe
FileName : C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
BaseAddress : 10682368
ModuleMemorySize : 868352
EntryPointAddress : 10980160
FileVersionInfo : File: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
InternalName: chrome_exe
OriginalFilename: chrome.exe
FileVersion: 28.0.1500.72
...
Run Code Online (Sandbox Code Playgroud)
尝试相同的我想要的东西虽然不起作用:
PS> Get-WmiObject Win32_ComputerSystem | select -Property __CLASS,__SUPERCLASS,__DYNASTY -expand __DERIVATION | fl
CIM_UnitaryComputerSystem
CIM_ComputerSystem
CIM_System
CIM_LogicalElement
CIM_ManagedSystemElement
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,只显示了展开属性的内容; 其他一切都被跳过了.
这是没有扩展属性的输出:
PS> Get-WmiObject Win32_ComputerSystem | select -Property __CLASS,__SUPERCLASS,__DYNASTY,__DERIVATION | fl
__CLASS : Win32_ComputerSystem
__SUPERCLASS : CIM_UnitaryComputerSystem
__DYNASTY : CIM_ManagedSystemElement
__DERIVATION : {CIM_UnitaryComputerSystem, CIM_ComputerSystem, CIM_System, CIM_LogicalElement...}
Run Code Online (Sandbox Code Playgroud)
关于我可能做错什么或者为什么这不起作用的任何建议?
谢谢,拉克什
这是设计的.您需要自定义属性.试试这个:
Get-WmiObject Win32_ComputerSystem |
select __CLASS,__SUPERCLASS,__DYNASTY,@{n="__DERIVATION";e={($_ | select -expa __DERIVATION) -join ',' }}| fl *
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9150 次 |
最近记录: |