Forked from norman-bauer/Configure-DHCPOption119OnScope.ps1
Created
November 21, 2022 23:58
-
-
Save M43R/d20a7b99a71618ff62c53827be62acb5 to your computer and use it in GitHub Desktop.
Asks for a list of semicolon separated domain suffixes and a Windows Server DHCP Scope Id on which Option 119 will be configured accordingly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$domainSearchList = Read-Host "Please enter a list of domain suffixes separated by semicolons (e.g. domain.local;domain.tld;int.domain.tld)" | |
$scopeToConfigure = Read-Host "Please enter the scope id of the scope to be configured (e.g. 192.168.1.0)" | |
$splittedDomainSearchList = $domainSearchList -split "\;" | |
$domainSearchListHexArray = @(); | |
Foreach ($domain in $splittedDomainSearchList) | |
{ | |
$splittedDomainParts = $domain -split "\." | |
Foreach ($domainPart in $splittedDomainParts) | |
{ | |
$domainPartHexArray = @() | |
$domainPartHexArray += $domainPart.Length | |
$domainPartHexArray += $domainPart.ToCharArray(); | |
Foreach ($item in $domainPartHexArray) | |
{ | |
$domainSearchListHexArray += [System.Convert]::ToUInt32($item) | |
} | |
} | |
$domainSearchListHexArray+= 0x00 | |
} | |
Set-DhcpServerv4OptionValue -ScopeId $scopeToConfigure -OptionId 119 -Value $domainSearchListHexArray |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment