CimClass的成员通过管道有所不同

时间:2019-07-01 14:09:04

标签: powershell

我希望从以下两个命令中获得相同的“类型”。第二种在类型名称前加上“已选择”。

>(Get-CimInstance CIM_LogicalDisk).CimClass | gm

   TypeName: Microsoft.Management.Infrastructure.CimClass

Name                MemberType     Definition
----                ----------     ----------
Dispose             Method         void Dispose(), void IDisposable.Dispose()
Equals              Method         bool Equals(System.Object obj)
GetHashCode         Method         int GetHashCode()
GetType             Method         type GetType()
ToString            Method         string ToString()
CimClassMethods     Property       Microsoft.Management.Infrastructure.Generic.CimReadOnlyKeyedCollection[Microsoft.M
CimClassProperties  Property       Microsoft.Management.Infrastructure.Generic.CimReadOnlyKeyedCollection[Microsoft.M
CimClassQualifiers  Property       Microsoft.Management.Infrastructure.Generic.CimReadOnlyKeyedCollection[Microsoft.M
CimSuperClass       Property       cimclass CimSuperClass {get;}
CimSuperClassName   Property       string CimSuperClassName {get;}
CimSystemProperties Property       Microsoft.Management.Infrastructure.CimSystemProperties CimSystemProperties {get;}
CimClassName        ScriptProperty System.String CimClassName {get=[OutputType([string])]...

第二个显示了不同的类型。

>Get-CimInstance CIM_LogicalDisk | Select-Object -Property CimClass | gm


   TypeName: Selected.Microsoft.Management.Infrastructure.CimInstance

Name        MemberType   Definition
----        ----------   ----------
Equals      Method       bool Equals(System.Object obj)
GetHashCode Method       int GetHashCode()
GetType     Method       type GetType()
ToString    Method       string ToString()
CimClass    NoteProperty cimclass CimClass=root/cimv2:Win32_MappedLogicalDisk

>$PSVersionTable.PSVersion.ToString()
5.1.14409.1018

1 个答案:

答案 0 :(得分:0)

Select-Object-Property参数一起使用将输出具有选定属性的对象。

要获取“裸露”属性值,请改用-ExpandProperty参数。

Get-CimInstance CIM_LogicalDisk | Select-Object -ExpandProperty CimClass | gm