4

In Active Directory, you can map IP addresses to Client Sites.

enter image description here

...and then you can map Group Policy objects to sites.

enter image description here

Which is great and all, but I have a client that is growing rapidly, and they expect to have hundreds of sites in the next year or two.

Our naming standard is loosely based on LOCODE, so every site is 7 characters--for example 'USHQZOF'. That prefix is used to name every machine.

I'm getting sick of creating the same basic policy everywhere.

It literally follows the format:

  • Map drive O to \\USHQZOFSRV01\officeshare
  • Map primary printer to \\USHQZOFSRV01\copier

I'd really love it if I could create a policy where I can say:

  • Map drive O to \\(site-name-from-ad)SRV01\officeshare
  • Map primary printer to \\(site-name-from-ad)SRV01\copier

...and be done with it for good.

It appears you can use a ton of environment variables in your Group Policy Preferences (https://technet.microsoft.com/en-us/library/Cc753915.aspx), but I don't see anything for the Client Site Name.

Am I out of luck, or do I need to go 'old school' and call a cscript/vbscript file during login that looks it up and maps the appropriate items?

(edit: I know it can be done with a VBS file--I've done it before. It just seems...unclean...)

2 Answers 2

5

is my first time i try to help

I had this problem also, and i solve it using dns defaul behavior Prioritizing local subnets https://technet.microsoft.com/en-us/library/cc787373(v=ws.10).aspx

So in your case just need to create a A Record for your sites fs Servers with the name SRV01

And then just create one gpo to mount And add the default print with srv01\ And link it to every site

And when a client in the site ask for srv01, the dns will return the correct ip address for srv01 for that site

2
  • That's a nice trick. I always had a suspicion Windows did that, but never looked... Jul 25, 2015 at 8:08
  • I tried this. It doesn't appear to work. I created 3 DNS entries for 'localnas' under the customer domain and tested from the three sites that are local to the NAS based on Active Directory Sites and Services. I appear to randomly hit a NAS and then stick with until reboot. I verified this by creating a a uniquely-named file on each NAS under the officeshare. I also tested this over several days after several reboots to ensure it wasn't a delay in GPO replication. Also, pinging 'localnas' will randomly return an IP if I 'ipconfig /flushdns' in between pings. Aug 29, 2015 at 16:53
1

if you are still curious about a VBS, this code will set the site name to a system variable.

'--- Get Site name ---
Set strSysinfo = CreateObject("ADSystemInfo")
strCurrentSite=strSysinfo.Sitename

'--- Write site name to system variables ---
Set objShell = CreateObject("WScript.Shell")
Set objSystemEnv = objShell.Environment("SYSTEM")
objSystemEnv("SiteName") = strCurrentSite

'--- Clean ---
Set strSysinfo = Nothing
Set objShell = Nothing
Set objSystemEnv = Nothing
1
  • This actually sounds like a great idea. I tweaked the script a bit and pushed it out. I'll do some testing over the next few weeks to see how it handles things like mapping drives and handling folder redirection. Especially since it may be possible the variable hasn't been created yet and you are trying to map "My Documents" to a local storage NAS. Mar 4, 2016 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .