Is it possible to utilize splatting when constructing an object from a custom class? I get an error when I try it. But I thought maybe theres some other way.
To use splatting in PowerShell you must use the at symbol (@) not the dollar sign ($). Unfortunately for a class it doesn’t appear possible to use the splatting method. And is still under consideration from Microsoft.
Yep, casting a hashtable to a class type will always work if:
the type has a public parameterless constructor
the members you're trying to set with the hashtable are public and settable
Both of these are presently always true for classes constructed with PS's class syntax. However, it also works for any .NET types that satisfy those constraints. :)