I want to create an object of arbitrary values, sort of like how I can do this in C#
var anon = new { Name = \"Ted\", Age = 10 };
Try this:
PS Z:\> $o = @{} PS Z:\> $o.Name = "Ted" PS Z:\> $o.Age = 10
Note: You can also include this object as the -Body of an Invoke-RestMethod and it'll serialize it with no extra work.
-Body
Invoke-RestMethod
Note the comments below. This creates a hashtable.