I have one class with default value for Status Message:
class DeploymentState {
[string] $StatusMessage
DeploymentState() {
$this.StatusMessage = "initial status."
}
}
I have Second Class which references the first one:
class Component {
[DeploymentState] $dstate
}
$c=[Component]::new()
$c.dstate.StatusMessage
I am not getting anything as output for this? Help - what I am missing? Even if I instantiate the class the result is the same:
$dstate=[DeploymentState]::new()
$c.dstate.StatusMessage
Thanks
Try this
You will also need a constructor inside your Component class in which you create a new instance of your $dstate property, else it will be null, that's why there's no output.
Now the following gives you a result
and this one also