-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Needs-ReproThe issue author needs to provide repro steps.The issue author needs to provide repro steps.Resolution-DuplicateThe issue is a duplicate.The issue is a duplicate.
Description
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
It would appear [PSCustomObject] is broken. I realized this because a lot of code stopped working after upgrading to 7.4. In 5.1 same code still works. Consider this test:
Clear-Host
Write-Host ''
Write-Host 'Hash:' -ForegroundColor Green
$newHash = @{
AppId = '12341234'
Version = '23452345'
Name = 'whatever'
Publisher = 'default'
}
$newHash
Write-Host ''
Write-Host 'Object with [PSCustomObject]:' -ForegroundColor Green
$newObject = [PSCustomObject]$newHash
$newObject
Write-Host ''
Write-Host 'Object with New-Object:' -ForegroundColor Green
$newObject = New-Object -TypeName psobject -Property $newHash
$newObject
Write-Host 'Done.' -ForegroundColor Green
Expected behavior
Hash:
Name Value
---- -----
AppId 12341234
Publisher default
Name whatever
Version 23452345
Object with [PSCustomObject]:
AppId : 12341234
Publisher : default
Name : whatever
Version : 23452345
Object with New-Object:
AppId : 12341234
Publisher : default
Name : whatever
Version : 23452345
Done.Actual behavior
Hash:
Name Value
---- -----
Version 23452345
Publisher default
AppId 12341234
Name whatever
Object with [PSCustomObject]:
Object with New-Object:
Version : 23452345
Publisher : default
AppId : 12341234
Name : whatever
Done.Error details
No response
Environment data
Both environments:
PS C:\Projects\__KB\Docker> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22000.2600
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.2600
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS C:\Projects\__KB\Docker> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
ChristopherGLewis
Metadata
Metadata
Assignees
Labels
Needs-ReproThe issue author needs to provide repro steps.The issue author needs to provide repro steps.Resolution-DuplicateThe issue is a duplicate.The issue is a duplicate.

