I spent quite a while looking for a DSC (Desired State Configuration) module to set the Primary DNS Suffix without much luck.
Specifically, I was looking to set this field:
This is what I managed to get working.
$dnsSuffix = "contoso.com"
Script SetDNSSuffix
{
SetScript =
{
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name Domain -Value $dnsSuffix
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -Value $dnsSuffix
}
TestScript =
{
$currentSuffix = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -ErrorAction SilentlyContinue)."NV Domain"
if ($currentSuffix -ne $dnsSuffix){
return $false
}
return $true
}
GetScript =
{
$currentSuffix = (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -ErrorAction SilentlyContinue)."NV Domain"
return $currentSuffix
}
}
- SetScript - Fires when the value needs to be set
- TestScript - Fires to test whether the value needs to be set
- GetScript - Gets the currently set value