· 4 years ago · Dec 09, 2020, 09:30 AM
1Configuration xDhcpsServerScope_NewScope
2{
3 Import-DscResource -ModuleName xDHCpServer
4 #Define NIC IP
5 $IP = Get-NetIPAddress -InterfaceAlias "Ethernet 2" | Where-Object {$_.IPAddress -notlike "*:*" } | select -ExpandProperty IPAddress
6 Node 'localhost'
7 {
8 WindowsFeature 'RSAT-DHCP'
9 {
10 Name = 'RSAT-DHCP'
11 Ensure = 'Present'
12 }
13 WindowsFeature 'DHCP'
14 {
15 Name = 'DHCP'
16 Ensure = 'Present'
17 }
18
19 xDhcpServerAuthorization RemoteServerActivation
20 {
21 Ensure = 'Present'
22 DnsName = $env:COMPUTERNAME + '.party.hard'
23 IPAddress = $IP
24 }
25
26
27 xDhcpServerScope Scope
28 {
29 ScopeId = '192.168.11.0'
30 Ensure = 'Present'
31 IPEndRange = '192.168.11.254'
32 IPStartRange = '192.168.11.10'
33 Name = '11.0/24'
34 SubnetMask = '255.255.255.0'
35 LeaseDuration = ((New-TimeSpan -Hours 8 ).ToString())
36 State = 'Active'
37 AddressFamily = 'IPv4'
38 }
39
40 xDhcpServerOption Option
41 {
42 Ensure = 'Present'
43 ScopeID = '192.168.11.0'
44 DnsDomain = 'party.hard'
45 DnsServerIPAddress = '192.168.11.2'
46 AddressFamily = 'IPv4'
47 Router = '192.168.11.1'
48 }
49 }
50}
51xDhcpsServerScope_NewScope
52Start-DscConfiguration -Path .\xDhcpsServerScope_NewScope -Force -Wait -Verbose