SQL Query monitor in powershell

I need to make a monitor in powershell to query a sql database. The database is on a always on availability group. Can I query the database via the availability group or do I need to choose one node for the database?
When I need to choose a node, what when this node is offline?
Kind regards,

Not really a SquaredUp topic, but you query the DB via the AG listener. That way it fails over if a node fails.
If you target a node, then your monitor will fail if the node fails.
HTH - M.