https://wordsontech.com/how-to-run-a-script-on-all-databases-that-are-either-ag-primary-or-standalone-in-sql-instance/
How to run a script on all databases that are either AG primary or standalone in SQL instance