# Possible to deploy DHCP via Group Policy?



## kbcs6dpm (Apr 17, 2007)

Hello, i was wondering if any of you could advise?

I'm wanting to convert our Windows 2000 & XP workstations from static IP addresses to DHCP. We have a DHCP server (Windows 2003) up and ready.

Is it possible to deploy DHCP to our workstations using Active Directory Group Policy, rather than going round each machine manually?

Any advice would be grateful. Thanks.


----------



## StumpedTechy (Jul 7, 2004)

Aha a problem I had. You can't change it via GPO (at least anyhow that I found).

You can do this - put -

On Error Resume Next
strComputer = InputBox("Type in the Computer Name","Computer Name Variable")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableDHCP()
objNetAdapter.SetDNSServerSearchOrder()
objNetAdapter.SetDynamicDNSRegistration FULL_DNS_REGISTRATION, _
DOMAIN_DNS_REGISTRATION
NEXT

into a script and this will hit the PC and have it change to DHCP and set DNS to also be set to DHCP - most have that hardcoded as well.

The main thing to remember is this will for a brief minute disconnect the client so don't run it at production time.


----------



## StumpedTechy (Jul 7, 2004)

Also change this line -

strComputer = InputBox("Type in the Computer Name","Computer Name Variable")

to any VBS way you want you can do -

strComputer = "."

to do it to the local machine or parse out some txt file and put it in as strComputer.


----------



## kbcs6dpm (Apr 17, 2007)

Thanks for your answers. After some research, i found out that it's not possible with Active Directory group policy.

But you can use a start up script in group policy that will change the settings over to DCHP when the client machine boots up.

The script to use is located here:
http://www.microsoft.com/technet/scriptcenter/scripts/network/client/modify/default.mspx?mfr=true

To learn more about scripting, start here:
http://www.microsoft.com/technet/scriptcenter/topics/beginner/firststeps.mspx


----------



## StumpedTechy (Jul 7, 2004)

I wouldn't do a startup script.... anything else in there that deals with network connectivity will drop when they change from static to DHCP. I would do it as a one time only thing.


----------

