WildCard to Skip Synchronized DB I am running a security RAG on reporting server that updates our security and put database to read_only mode. I am using wildcard to skip system and some other databases, but what can I use to skip any database that's a part of AG. in other words what can I use to skip synchronized DB?

Thank you.
but what can I use to skip any database that's a part of AG. in other
  words what can I use to skip synchronized DB?


There is a difference between  getting any database that belongs to an AG or to only get the synchronized databases. For example, async nodes will keep having the status: "synchronizing" (or another message, but not synchronized).

To get all the databases participating in an AG:

SELECT name 
FROM sys.databases 
WHERE database_id 
NOT IN (SELECT database_id  
        FROM sys.dm_hadr_database_replica_states);


To get only the synchronizing databases:

SELECT name 
FROM sys.databases 
WHERE database_id 
NOT IN (SELECT database_id  
        FROM sys.dm_hadr_database_replica_states 
        WHERE synchronization_state_desc = 'SYNCHRONIZED');


To also exclude the system db's:

SELECT name 
FROM sys.databases 
WHERE database_id 
NOT IN (SELECT database_id  
        FROM sys.dm_hadr_database_replica_states 
        WHERE synchronization_state_desc = 'SYNCHRONIZED')
        AND database_id &gt; 4;