David Fowler shows how you can find the primary node of an Availability Group using Powershell:
A while back, Adrian put together a bunch of queries for Always On Availability Groups,
7 ways to Query Always On Availability Groups using SQL
7 more ways to Query Always on Availability groupsBut he never actually answered that particular question.
Click through for the script.