Script to remove DNS suffix for source domain.

Hello,
 We are migrating from source to target domain and  need to get rid of source domain suffix if it is listed under "Append these suffixes in order" and add the suffix for the target domain instead. Is there a script that can remove suffix for the old source domain and add the new domain suffix?

THank you very much.
creative555Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Refer to link below, this way you could set the suffix to what you want using PowerShell:

http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_27082313.html
oBdACommented:
Try this; note that the script needs to be run elevated:
$OldSuffix = "foo.bar"
$NewSuffix = "new.bar"
$Nics = Get-WmiObject -Namespace "Root\CIMv2" -Query "Select * From Win32_NetworkAdapterConfiguration Where IPEnabled='True'"
$DNSDomainSuffixSearchOrder = @()
ForEach ($Nic In $Nics) {
	If ($Nic.DNSDomainSuffixSearchOrder -contains $OldSuffix) {
		$DNSDomainSuffixSearchOrder = $Nic.DNSDomainSuffixSearchOrder -replace $OldSuffix, $NewSuffix
		Break
	}
}
If ($DNSDomainSuffixSearchOrder.Count -gt 0) {
	"Setting new DNS Suffix Search Order: $($DNSDomainSuffixSearchOrder -join ',') ..."
	$Result = ([wmiclass]"Win32_NetworkAdapterConfiguration").SetDNSSuffixSearchOrder($DNSDomainSuffixSearchOrder)
	If ($Result.ReturnValue -eq 0) {
		"... OK."
	} Else {
		"Error '$($Result.ReturnValue)' when setting the new DNS suffix search order!" | Write-Error
	}
} Else {
	"DNS Suffix '$($OldSuffix)' not found."
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
creative555Author Commented:
Excellent! Exactly what I needed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.