Thursday, January 16, 2014

Part 2–: PowerShell and DHCP : DHCP Post-Install Configuration


Part – 1 : PowerShell and DHCP : Installing DHCP Server Role on Server 2012

Doing Post-Install Configuration tasks


In my previous post, we go through the steps for installing the DHCP Server role on our windows server 2012. In this post we are going to do the DHCP Post Configuration tasks, which contains two steps for a standalone (Workgroup) server.
1.       Creating Security Groups
a.       DHCP Administrators
b.      DHCP Users
2.       Supressing the post-install configuration alert.

Note: I am running a non-domain server, which is just a standalone workgroup computer, if you want to do post-installation configuration on domain joined server, than the few steps are different as per compared to the workgroup server.

After installing the DHCP server roles, we have to complete the DHCP Server Post installation tasks. 

So, when you open the server manager console, you will see the below warning error, “Configuration required for DHCP Server at DHCP-Server1.

1

When you click on it, it will ask you to complete an action to Complete DHCP Configuration.

2
When you click on “Complete DHCP configuring”, you will see that it will ask to create 2 Security groups, one is “DHCP Administrators” and another one is “DHCP Users”.
Now Click on Cancel, yes on Cancel and go back to our PowerShell Console.

3

As, I told you before, that we will try to configure DHCP Server using PowerShell as much as we can.

Note : With Server 2012 R2, you can use the Add-DHCPServerSecurityGroup to add the two groups.No need to manually add them using ADSI! (Thanks to Sir Thomas Lee for suggestions.

Now, run the below script and then open Local users and Groups.

# Creating a group for DHCP Server
   # This Step is required for WorkGroup only server,
   # If your server is joined to the Domain, this steps are not valid.

$objectOU = [ADSI]"WinNT://$env:COMPUTERNAME"
$group = $objectOU.Create("Group","DHCP Users")
$group.CommitChanges()

$groupAdmin = $objectOU.Create("Group","DHCP Administrators")
$groupAdmin.CommitChanges()


4

Once you run the above script, you, can see that desired groups are created.

5

But, when you open Server Manager Console again you will see the same error again.

6

To supress this error, we need to change a registry settings, and then we need to restart the DHCP Server Service.
Run the below command to change the Registry value, to change the registry value, run the below command.

Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\ServerManager\Roles\12 -Name ConfigurationState -Value 2

7

Now, restart the DHCP Server Service.
Restart-Service -Name DHCPServer –Force

8

Now, open Server Manager again, and you can see there are not errors related to “DHCP Server Post Configuration”.
9

That’s all.
Now our POST configuration task is done, now next we have to start configuring the server…


Regards
Aman Dhally
clip_image017 clip_image018 clip_image019 clip_image020  clip_image021


3 comments:

  1. With Server 2012 R2, you can use the Add-DHCPServerSecurityGroup to add the two groups.No need to manually add them using ADSI!

    ReplyDelete
    Replies
    1. Sir Thomas, WOW!!!

      It's an honour to see your suggestion on my blog. WOW !!!!! Thanks a lot for suggestion Sir, I think I am using Server 2012 Standard Edition, that's why I am not able to see that CMDLET

      Thanks a lot Sir.

      Regards
      Aman

      Delete
    2. Good post...!
      But in case of server joined to a domain or DC ,
      what are the steps for DHCP Administrator....?

      Thx

      Delete

Note: Only a member of this blog may post a comment.