Hello,
Thank you for posting in Microsoft Q&A.
Based on the description, I understand your question is related to Remove-PhysicalDisk is denied.
I understand that you would like us to look at the scripts, but understand that detailed analysis of the scripts will require more professional resources and this may be beyond the range of this forum.
However, I found an official link which provides detailed scripts and example of Remove-PhysicalDisk, you can take it as a reference:
Have a nice day.
Best Regards,
Molly
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it