macos – Scripting the repositioning and refreshing of menu bar icons?

When menu bar items are rearranged using Cmd+drag, macOS writes a new “preferred position” preference to each app that is showing a menu bar icon.

This helps, but does not guarantee, that they retain their position for subsequent launches.

How can I script the repositioning, or trigger the writing of the new preferences?