Configure DHCP Policies to support BIOS & UEFI boot for SCCM
This script will generate required DHCP configuration to support of Legacy BIOS and UEFI PXE boot at the same time for SCCM.
# -------------------- Configuration ------------------------------
$DhcpServer = "localhost"
$ScopeId = "10.0.0.0"
$PxeServer = "sccm.contoso.com"
# -----------------------------------------------------------------
$vendorClasses = @(
@{
Name = "PXEClient UEFI (x64)"
Data = "PXEClient:Arch:00007"
BootImage = "smsboot\x64\wdsmgfw.efi"
},
@{
Name = "PXEClient UEFI (x86)"
Data = "PXEClient:Arch:00006"
BootImage = "smsboot\x86\wdsmgfw.efi"
},
@{
Name = "PXEClient BIOS (x86 & x64)"
Data = "PXEClient:Arch:00000"
BootImage = "smsboot\x64\wdsnbp.com"
}
)
# Create Vendor Prefix classes
$vendorClasses | ForEach-Object {
$parameters = @{
Name = $_.Name
Description = $_.Data
Data = $_.Data
Type = "Vendor"
}
Add-DhcpServerv4Class -ComputerName $DhcpServer @parameters
}
# Create Scope policies
$vendorClasses | ForEach-Object {
Add-DhcpServerv4Policy -ComputerName $DhcpServer `
-ScopeId $ScopeId `
-Name $_.Name `
-Condition OR `
-VendorClass EQ,"$($_.Name)*"
}
# Set policy options
$vendorClasses | ForEach-Object {
Set-DhcpServerv4OptionValue -ComputerName $DhcpServer `
-ScopeId $ScopeId `
-PolicyName $_.Name `
-OptionId 66 `
-Value $PxeServer
Set-DhcpServerv4OptionValue -ComputerName $DhcpServer `
-ScopeId $ScopeId `
-PolicyName $_.Name `
-OptionId 67 `
-Value $_.BootImage
}
# Remove default scope options (66, 67)
66, 67 | ForEach-Object {
Remove-DhcpServerv4OptionValue -ComputerName $DhcpServer `
-ScopeId $ScopeId `
-OptionId $_ `
-Confirm:$false `
-ErrorAction SilentlyContinue
}