PowerShell HashTable - self referencing during initialization

This won't be possible using the object initializer syntax I'm afraid. While it is possible to use variables, you'll have to compute the values before creating the object.


I cannot recommend this, but you can iterate the initializer twice or more:

(0..1) | %{
    $a = @{
        One = 1
        Two = $a.One + 1
    }
}

(0..2) | %{
    $b = @{
        One = 1
        Two = $b.One + 1
        Three = $b.Two + 1
    }
}

Make sure all calculations are idempotent, i.e. do not depend on a number of iterations.