How to link GPO to domain via Powershell script when you dont know domain name

I have a GPO called taco that I created with powershell script.   I need to link this to the domain but I don't know what the name of the domain is.   This is a generic powershell script that my customers will use to link the taco GPO to their individual domains.  I need to call the domain, find the FQDN and then insert it into this script:

-name Taco | new-gplink -target "ou=????,dc=?????,dc=?????" | set-gppermissions -permissionlevel gpoedit -targetname "Domain Admins " -targettype group

I need to figure out how to get those ???? populated in the script.  windows server 2008 R2

hope that makes sense :)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
Import-module ActiveDirectory
$ou = "OU_NAME_Here"

$dn = (get-ADDomain).DistinguishedName

-name Taco | new-gplink -target "ou=$ou,$dn" | set-gppermissions -permissionlevel gpoedit -targetname "Domain Admins " -targettype group

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gmckfnAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.