PowerShell has its own serializer.
Why?
Because I never trusted the .Net serializers.
After 10+ years, our first major security bug (found with via a Red Team) was a serialization problem.
Someone didn’t get the memo and used a .Net serializer - exactly once.
Don't write your own serializer. Actually, writing one is much simpler if your type system is simple, but just don't.