Hi,
Please refer the scripts available in the below links,
Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
Also, suggest to run the powershell commands in a test environment before trying in production.