Skip to content

Instantly share code, notes, and snippets.

@DXPetti
Created August 22, 2018 08:05
Show Gist options
  • Save DXPetti/d11f5e812ff3a31a2cbedecac796301e to your computer and use it in GitHub Desktop.
Save DXPetti/d11f5e812ff3a31a2cbedecac796301e to your computer and use it in GitHub Desktop.
<#
.DESCRIPTION
Powershell script to add DHCP vendor class and policies to allow Legacy BIOS based network booting (PXE) based upon information sent by client detailed in RFC 4578 (https://tools.ietf.org/html/rfc4578)
.PARAMETERS
None - execute directly from Powershell
.VERSION
1.0
.AUTHOR
James Pettigrove
.COMPATIBILITY
Windows 7, Windows 10
.RELEASE DATE
06/04/2017
.NOTES
v1.0, 20170401 - Initial Version
#>
$dhcpServers = Get-DhcpServerInDC
$className = "PXEClient(Legacy BIOS)"
$classData = "PXEClient:Arch:00000"
$classDesc = "PXEClient:Arch:00000"
$policyName = "Legacy BIOS"
$policyDesc = "Policy for Legacy BIOS based network booting"
[array]$dhcpScopes = (Read-Host "Enter DHCP Scopes (separate with comma) to apply Legacy BIOS boot option").split(",") | %{$_.trim()}
foreach ($dhcpServer in $dhcpServers) {
Write-Host -ForegroundColor Yellow "Checking if $className exists on $dhcpServer"
$classExist = Get-DhcpServerv4Class -ComputerName $dhcpServer -Name $className -Type Vendor -ErrorAction SilentlyContinue
if (-Not $classExist) {
Write-Host -ForegroundColor Yellow "Adding $className to $dhcpServer"
Add-DHCPServerv4Class -ComputerName $dhcpServer -Name $className -Type Vendor -Data $classData -Description $classDesc
}
Foreach ($dhcpScope in $dhcpScopes) {
Write-Host -ForegroundColor Yellow "Adding $policyName to $dhcpScope"
Add-DhcpServerv4Policy -ComputerName $dhcpServer -ScopeId $dhcpScope -Name $policyName -Description $policyDesc -Enabled $true -Condition OR -VendorClass EQ,"$className*"
Set-DhcpServerv4OptionValue -ComputerName $dhcpServer -ScopeId $dhcpScope -PolicyName $policyName -OptionId 066 -Value "PXESERVER.local"
Set-DhcpServerv4OptionValue -ComputerName $dhcpServer -ScopeId $dhcpScope -PolicyName $policyName -OptionId 067 -Value "SMSBoot\x86\wdsnbp.com"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment