Steps to reproduce
#Sub.psm1:
class Sub {
[int] $Value
}
#modrepo.psm1:
using module .\Sub.psm1
function Get-Sub {
[Sub]@{
Value = 42
}
}
Import-Module modrepo
Get-Sub
Value : 1
Change the definition of Sub:
#Sub.psm1:
class Sub {
[string] $Name # added field
[int] $Value
}
#modrepo.psm1:
using module .\Sub.psm1
function Get-Sub{
[Sub]@{
Name = ‘Staffan’ # added field
Value = 42
}
}
#Then
Remove-Module -force modrepo
Import-Module -force modrepo
Get-Sub
Expected behavior
output of object of class Sub with
Name : 'Staffan'
Value : 42
Actual behavior
Cannot create object of type "Sub". The Name property was not found for the Sub object. The available property is: [Value <System.Int32>]
At C:\Users\<user>\Documents\WindowsPowerShell\Modules\modrepo\modrepo.psm1:9 char:3
+ [Sub] @{
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : ObjectCreationError
Environment data
Name Value
---- -----
PSVersion 5.1.14393.206
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.206
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Steps to reproduce
Value : 1Change the definition of Sub:
Expected behavior
output of object of class Sub with
Actual behavior
Environment data