Need to install TeamViewer on a headless Mac in a remote location

So I have been tasked with getting TeamViewer installed on a bunch of MacMini's we have in remote locations.  My problem?  I need to be able to download, install and run TeamViewer from the CLI via SSH.  How would I go about this?  I've searched online and haven't found a solution that works for me at this point.  And then once it's installed, how do I get the ID so I can connect to the machine?  These machines are running anything from 10.6.8 to 10.12.  

Tagged: