After enable AutoMapping, shared mailbox will show in Outlook client automatically without any other action. When login mailbox in new client, the shared mailbox will also show automatically.
So, I am confused, you don’t want the mailbox to appear automatically, but you also want to use a script to add it automatically. Why do you want to do this?
If you really want to do it, you can try to post this question in Outlook for Developers forum. It may be help to you.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.