How to access computer tag within a script

We need to create a script that will check the internal tag ROT-Location and then check the current work group. if workgroup name does not = location AND the computer is not on a domain, then change the workgroup name to the location.
Is there a parameter we can access within a script that will allow us to do this?