Post

I've been experimenting with PSObject binary encodings to replace CLIXML - CBOR and Protobuf are both great candidates, with significantly smaller size, but also much faster encoding and decoding performance! Which one would you like to be supported natively in PowerShell?

1 repost12 likes

If speed if your jam then encoding the strings as UTF-16 might be better than UTF-8 as it won’t require an encoding/decoding trip. It’s also more memory efficient when it comes to non-ASCII heavy languages. I’m sure your French might benefit if you use more of those fancy diacritics :)

Not sure how much my vote counts, but I'd say: Why not both? CBOR if I had to choose, but both have active ecosystems, and both would be good ecosystems to be able to work with. PowerShell should always be able to talk to as many standards as is possible and simple.

Cool! I have one simple additional ask, strange as it might seem: Allow a custom transform (preferably thru a [ScriptBlock] or [func[PSObject]] ) The goal here would not be universal operability, but specific high-performance compatibility. Otherwise it's always 'select *'

You mean combine Select-Object with the object exporting/importing? I'm building cmdlets for PSObject serialization/deserialization to go along my PSRemoting module right now

CBOR for me, and gRPC needn't change that, since it defaults to Protobuf but carries other formats too. Would PSRemoting over gRPC pass objects as an opaque blob, or map them into proper messages?

I could use gRPC as the protocol envelope for MS-PSRP, passing CBOR-encoded PowerShell objects, but since gRPC is using Protobuf, it might be nice to stick to Protobuf at all layers. I would prefer CBOR too, I'm undecided

JSON or BSON are excluded, as they can't preserve 100% of PowerShell object properties the same way CLIXML would. I've tested the CBOR and Protobuf encodings to make sure all edge cases survive an encoding round trip

Notice how I haven't tried ASN.1 😅 but seriously though, CBOR is schema-less and great, Protobuf requires a schema, but could still be adapted to map CLIXML well. Protobuf is what gRPC uses, so the next step would be gRPC-based PSRemoting