How to make array-curve instances perpendicular to XY

This question appears to have been asked before but I cannot seem to find a specific answer. So apologies if this has already been answered somewhere.

I am using an array attached to a curve to make a fence, and would like the posts to remain perpendicular to XY, not to the curve. (It’s OK if there is some distortion in the cross members.)

As a workaround I’ve been using proportional editing to shift fence sections manually in Z. But I would prefer a nondestructive solution.

Possible or not?

Using Blender 2.92. Thanks.