PowerShell / PowerShell/PowerShell
`ConvertTo-Json` neglects to serialize ETS properties when passed output from CDXML cmdlets (CIM instances) that isn't `[psobject]` wrapped by argument
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 55.5k
- Forks
- 8.5k
- Merge médio
- 1d 2h
- PRs com merge (30d)
- 88
Descrição
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
Note:
-
This is yet another manifestation of https://github.com/PowerShell/PowerShell/issues/5579
-
Note that the problem only arises for CDXML cmdlets that do not themselves wrap their output objects in
[psobject], such asGet-PhysicalDisk,Get-VirtualDisk, andGet-Volume; others, such asGet-Disk, do perform this wrapping.
# Note: Since objects passing through the pipeline are automatically [psobject]-wrapped, the following
# pipeline alternative works correctly:
# Get-PhysicalDisk | ConvertTo-Json 3>$null | ConvertFrom-Json | Format-List
ConvertTo-Json (Get-PhysicalDisk) 3>$null | ConvertFrom-Json | Format-List
Expected behavior
CimClass : @{CimSuperClassName=MSFT_StorageFaultDomain; CimSuperClass=; CimClassProperties=System.Object[]; CimClassQualifiers=System.Object[];
CimClassMethods=System.Object[]; CimSystemProperties=}
CimInstanceProperties : {@{Name=ObjectId; Value={1}\\MKW11\root/Microsoft/Windows/Storage/Providers_v2\SPACES_PhysicalDisk.ObjectId="{47519af7-9162-11ee-9dc0-806e6f6e6963
}:PD:{f2881886-c54b-46f7-c1ac-8eb641e316de}"; CimType=14; Flags=35688452; IsValueModified=False}, @{Name=PassThroughClass; Value=; CimType=14;
Flags=572522500; IsValueModified=False}, @{Name=PassThroughIds; Value=; CimType=14; Flags=572522500; IsValueModified=False},
@{Name=PassThroughNamespace; Value=; CimType=14; Flags=572522500; IsValueModified=False}…}
CimSystemProperties : @{Namespace=root/microsoft/windows/storage; ServerName=MKW11; ClassName=MSFT_PhysicalDisk; Path=}
ClassName : MSFT_PhysicalDisk
Usage : Auto-Select
OperationalStatus : OK
# ... remaining properties omitted for brevity.
Actual behavior
CimClass : @{CimSuperClassName=MSFT_StorageFaultDomain; CimSuperClass=; CimClassProperties=System.Object[]; CimClassQualifiers=System.Object[];
CimClassMethods=System.Object[]; CimSystemProperties=}
CimInstanceProperties : {@{Name=ObjectId; Value={1}\\MKW11\root/Microsoft/Windows/Storage/Providers_v2\SPACES_PhysicalDisk.ObjectId="{47519af7-9162-11ee-9dc0-806e6f6e6963}:PD:{f2881
886-c54b-46f7-c1ac-8eb641e316de}"; CimType=14; Flags=35688452; IsValueModified=False}, @{Name=PassThroughClass; Value=; CimType=14; Flags=572522500;
IsValueModified=False}, @{Name=PassThroughIds; Value=; CimType=14; Flags=572522500; IsValueModified=False}, @{Name=PassThroughNamespace; Value=; CimType=14;
Flags=572522500; IsValueModified=False}…}
CimSystemProperties : @{Namespace=root/microsoft/windows/storage; ServerName=MKW11; ClassName=MSFT_PhysicalDisk; Path=}
That is, only the type-native properties were serialized, not also the ETS (adapted) ones.
Error details
No response
Environment data
PowerShell 7.5.0-preview.5 on Windows (also affects Windows PowerShell)
Visuals
No response
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece reproduzindo o exemplo de ConvertTo-Json (Get-PhysicalDisk) e compare-o com a forma usando pipeline. Investigue o caminho de serialização de ConvertTo-Json para instâncias CIM que não estão envolvidas por [psobject]. Está concluído quando propriedades ETS como Usage e OperationalStatus aparecem junto às propriedades nativas do tipo na saída serializada.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, powershell
- Domínio
- cli
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100