### Install DhcpServerDsc Module Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/Home Installs the DhcpServerDsc module from the PowerShell Gallery. Ensure you have PowerShellGet installed. ```powershell Install-Module -Name DhcpServerDsc -Repository PSGallery ``` -------------------------------- ### Install RSAT-DHCP Feature Source: https://github.com/dsccommunity/dhcpserverdsc/blob/main/tests/Unit/Stubs/README.md Installs the 'RSAT-DHCP' Windows feature. This is a prerequisite for creating stubs from the DhcpServer module. ```powershell Install-WindowsFeature -Name 'RSAT-DHCP' ``` -------------------------------- ### Create DHCP Server Option Definitions Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/xDhcpServerOptionDefinition This example demonstrates how to create multiple DHCP server option definitions using the xDhcpServerOptionDefinition resource. It includes examples for specific vendor classes and the default option class. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } xDhcpServerOptionDefinition 'DHCPServerOptionDefinition1' { Ensure = 'Present' Name = 'Cisco AP c1700 Provisioning' OptionID = '200' Type = 'IPv4Address' AddressFamily = 'IPv4' VendorClass = 'Cisco AP c1700' Description = 'Sample description' } xDhcpServerOptionDefinition 'DHCPServerOptionDefinition2' { Ensure = 'Present' Name = 'sample name' OptionID = '200' Type = 'IPv4Address' AddressFamily = 'IPv4' VendorClass = '' #default option class Description = 'Sample description' } xDhcpServerOptionDefinition 'DHCPServerOptionDefinition3' { Ensure = 'Present' Name = 'PXEClient' OptionID = '060' Type = 'String' AddressFamily = 'IPv4' VendorClass = '' #default option class Description = 'Sample description' DefaultValue = 'PXEClient' } } ``` -------------------------------- ### Configure DHCP Scope Options (Gateway, DNS, Domain) Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/DhcpScopeOptionValue This example demonstrates how to configure DHCP scope options for gateway, DNS servers, and domain name using the DhcpScopeOptionValue resource. Ensure the PSDscResources and DhcpServerDsc modules are imported. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } # Setting scope gateway DhcpScopeOptionValue 'ScopeOptionGateway' { OptionId = 3 Value = '1.1.1.1' ScopeId = '1.1.1.0' VendorClass = '' UserClass = '' AddressFamily = 'IPv4' } # Setting scope DNS servers DhcpScopeOptionValue 'ScopeOptionDNS' { OptionId = 6 Value = @('1.1.1.1', '2.2.2.2') ScopeId = '1.1.1.0' VendorClass = '' UserClass = '' AddressFamily = 'IPv4' } # Setting scope DNS domain name DhcpScopeOptionValue 'ScopeOptionDNSDomainName' { OptionId = 15 Value = 'contoso.com' ScopeId = '1.1.1.0' VendorClass = '' UserClass = '' AddressFamily = 'IPv4' } } ``` -------------------------------- ### Install StubCommand Module Source: https://github.com/dsccommunity/dhcpserverdsc/blob/main/tests/Unit/Stubs/README.md Installs the 'Indented.StubCommand' module from the PowerShell Gallery. This module is required to create stub functions. ```powershell Install-Module Indented.StubCommand -Scope CurrentUser ``` -------------------------------- ### Create a Vendor DHCP Server Class Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/xDhcpServerClass This snippet demonstrates how to create a new vendor DHCP server class using the xDhcpServerClass resource. Ensure the DHCP Windows Feature is installed and present before applying the configuration. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } xDhcpServerClass 'VendorClass' { ensure = 'Present' Name = 'VendorClass' Type = 'Vendor' AsciiData = 'sampledata' AddressFamily = 'IPv4' Description = 'Vendor Class Description' } } ``` -------------------------------- ### Verify DhcpServerDsc Module Installation Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/Home Confirms that the DhcpServerDsc DSC resources are available after installation. This command lists all DSC resources from the specified module. ```powershell Get-DscResource -Module DhcpServerDsc ``` -------------------------------- ### Configure DHCP Server Option Value Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/DhcpServerOptionValue This example demonstrates how to set DHCP option ID 8 (cookie servers) on a server level using the DhcpServerOptionValue DSC resource. Ensure the DHCP Windows feature is present before configuring the option. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } DhcpServerOptionValue 'ServerOptionValue_ID-008' { OptionId = 8 Value = '1.1.1.1' VendorClass = '' UserClass = '' AddressFamily = 'IPv4' Ensure = 'Present' } } ``` -------------------------------- ### Authorize Local DHCP Server Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/xDhcpServerAuthorization This snippet demonstrates how to authorize the local DHCP server. Ensure the PSDscResources module is imported. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } xDhcpServerAuthorization 'LocalServerActivation' { IsSingleInstance = 'Yes' Ensure = 'Present' } } ``` -------------------------------- ### Configure DHCP Server Reservation Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/xDhcpServerReservation This snippet demonstrates how to configure a DHCP server reservation using the xDhcpServerReservation DSC resource. Ensure the DHCP Windows Feature is present before configuring the reservation. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } xDhcpServerReservation 'PullServerIP' { Ensure = 'Present' ScopeID = '192.168.1.0' ClientMACAddress = '00155D8A54A1' IPAddress = '192.168.1.2' Name = 'DSCPullServer' AddressFamily = 'IPv4' } } ``` -------------------------------- ### Create Stub Module Source: https://github.com/dsccommunity/dhcpserverdsc/blob/main/tests/Unit/Stubs/README.md Creates a stub module for the 'DhcpServer' module in a specified destination folder. The stub function body is defined to throw an exception when called, indicating it's a stub. ```powershell $destinationFolder = 'c:\projects\stubs\' $functionBody = { throw '{0}: StubNotImplemented' -f $MyInvocation.MyCommand } New-StubModule -FromModule 'DhcpServer' -Path $destinationFolder -FunctionBody $functionBody ``` -------------------------------- ### Create or Modify a DHCP Server Scope Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/xDhcpServerScope This snippet demonstrates how to create a new DHCP server scope or modify an existing one using the xDhcpServerScope resource. It requires the PSDscResources and DhcpServerDsc modules to be imported. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } xDhcpServerScope 'Scope' { Ensure = 'Present' ScopeId = '192.168.1.0' IPStartRange = '192.168.1.1' IPEndRange = '192.168.1.254' Name = 'ContosoScope' SubnetMask = '255.255.255.0' LeaseDuration = ((New-TimeSpan -Hours 8).ToString()) State = 'Active' AddressFamily = 'IPv4' } } ``` -------------------------------- ### Configure DHCP Reserved IP Option Value Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/DhcpReservedIPOptionValue Sets DHCP option ID 8 (cookie servers) for a reserved IP address '192.168.0.1'. Ensure the DHCP Windows Feature is present before applying this configuration. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } DhcpReservedIPOptionValue 'ReservedIPOptionValue_ID-008' { ReservedIP = '192.168.0.1' OptionId = 8 Value ='1.1.1.1' VendorClass = '' UserClass = '' AddressFamily = 'IPv4' Ensure = 'Present' } } ``` -------------------------------- ### Set DHCP Option 8 at Server Level Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/DhcpPolicyOptionValue Configures DHCP option ID 8 (cookie servers) for a policy at the server level. Ensure the DHCP Windows Feature is present. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } DhcpPolicyOptionValue 'PolicyOptionValue_ID-008' { OptionId = 8 Value = '1.1.1.1' ScopeId = '' VendorClass = '' AddressFamily = 'IPv4' PolicyName = 'TestPolicy' Ensure = 'Present' } } ``` -------------------------------- ### Authorize Remote DHCP Server Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/xDhcpServerAuthorization This snippet shows how to authorize a remote DHCP server by specifying its DNS name and IP address. The DhcpServerDsc module must be imported. ```powershell configuration Example { Import-DscResource -moduleName 'DhcpServerDsc' xDhcpServerAuthorization 'RemoteServerActivation' { IsSingleInstance = 'Yes' Ensure = 'Present' DnsName = 'ServerToAuthorize.contoso.com' IPAddress = '192.168.0.1' } } ``` -------------------------------- ### Set DHCP Option 8 at Scope Level Source: https://github.com/dsccommunity/dhcpserverdsc/wiki/DhcpPolicyOptionValue Configures DHCP option ID 8 (cookie servers) for a policy within a specific scope. Ensure the DHCP Windows Feature is present. ```powershell configuration Example { Import-DscResource -ModuleName 'PSDscResources' -ModuleVersion '2.12.0.0' Import-DscResource -moduleName 'DhcpServerDsc' WindowsFeature 'DHCP' { Name = 'DHCP' Ensure = 'Present' } DhcpPolicyOptionValue 'PolicyOptionValue_ID-008-scope' { OptionId = 8 Value = '1.1.1.1' ScopeId = '192.168.0.0' VendorClass = '' AddressFamily = 'IPv4' PolicyName = 'TestPolicy' Ensure = 'Present' } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.