Члены CimClass отличаются через конвейер - PullRequest
0 голосов
/ 01 июля 2019

Я бы ожидал получить один и тот же «тип» от обеих следующих команд.Второй добавляет имя типа к «Выбранным».

>(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 голосов
/ 01 июля 2019

Использование Select-Object с параметром -Property выводит объект с выбранными свойствами.

Чтобы получить «голое» значение свойства, используйте вместо него параметр -ExpandProperty.

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

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...