Hi Éric,
I am afraid such programmatic options (to alter the pinned apps state) is forbidden by Microsoft. Microsoft firmly states that pinning/unpinning an app should be exclusively a manual (not programmatic) user choice.
Thank you for your understanding.
All the best,
Daniel