title: Using New-Object -Property to set properties of a nested class
body: <p>Lets say I define the following classes in C# inside a powershell script:</p>
  
  <pre><code>Add-Type -TypeDefinition @"
  public class InnerClass {
      int a, b;
      public int A { get { return a; } set { a = value; } }
      public int B { get { return b; } set { b = value; } }
  }
  public class SomeClass {
      string name;
      public string Name { get { return name; } set { name= value; } }
      InnerClass numbers;
      public InnerClass Numbers { get { return numbers; } set { numbers = value; } }
  }
  "@
  </code></pre>
  
  <p>I can instantiate an instance of <code>InnerClass</code> like so:</p>
  
  <pre><code>New-Object InnerClass -Property  @{
      'A' = 1;
      'B' = 2;
  }
  </code></pre>
  
  <p>However, if I want to instantiate <code>SomeClass</code> and set the properties for <code>InnerClass</code> in a similar manner, it fails.</p>
  
  <pre><code>New-Object SomeClass -Property @{
      'Name' = "Justin Dearing";
      Numbers = @{
          'A' = 1;
          'B' = 2;
      };
  } ;
  
  New-Object : The value supplied is not valid, or the property is read-only. Cha
  nge the value, and then try again.
  At line:20 char:11
  + New-Object &lt;&lt;&lt;&lt;  SomeClass -Property @{
      + CategoryInfo          : InvalidData: (:) [New-Object], Exception
      + FullyQualifiedErrorId : InvalidValue,Microsoft.PowerShell.Commands.NewOb 
     jectCommand
  
  
  
  Name    : Justin Dearing
  Numbers : 
  </code></pre>
  
  <p>Is there anyway to set <code>SomeClass</code>, including the properties of <code>Numbers</code> in one New-Object statement?</p>