Blue Flower

The following script shows how to update a DHCP servers with new options. Its finds one server address and if present updates it

 

cls
$DHCPServer="<DHCP Server>"
$OldServer"<Old Server Name>"
$NewServer="<New Server Name>"
$Bootname="\SMSBoot\x64\wdsnbp.com"

$arrDhcpScopes = Get-DhcpServerv4Scope -Computername $DHCPServer

Foreach ($line in $arrDhcpScopes)
{
$Scope= $line.ScopeId
write-host $Scope
$Opt66 = Get-DhcpServerv4OptionValue -ScopeID $Scope -OptionId 066 -Computername $DHCPServer
$BootServ = $Opt66.Value
Write-Host $BootServ
Write-HOst $OldServer

If ($BootServ -eq $OldServer)
{
Set-DhcpServerv4OptionValue -ScopeID $Scope -OptionId 066 -Value $NewServer -Computername $DHCPServer
Set-DhcpServerv4OptionValue -ScopeID $Scope -OptionId 067 -Value $Bootname -Computername $DHCPServer
Write-Host Success
}
Else
{
Write-Host Not a match
}
}