With AvePoint Cloud Governance you can define where you would like to have guest user access available, periodically check its status by notifying the person who is accountable for it, and directly give that person insight into who these guest users are. Auditors, admins, and security people can be given these insights into your Microsoft 365 tenant.
Simply running a script will not give you adequate control over your Microsoft 365 environment.