We currently convert user mailboxes to shared mailboxes during deprovisioning process but if the user mailbox was already a shared mailbox then the script throws an error because the mailbox cannot be converted to a shared bailbox.
How can I add a condition to the script to avoid the error? Also I would like to add a custom command to convert the user mailbox that is already a shared mailbox back to a user mailbox.
Here is the actions of the current deprovision command:

Thanks!