Avatar of Omar Lujan
Omar Lujan

asked on 

Powershell script change DNS

Hi Experts,

I'm trying to run the script from here out of the box

https://gallery.technet.microsoft.com/Modify-DNS-Server-0ec651e7

BatchModifyDNSConfiguration.ps1 -OU 'OU=FAKE GROUP, OU=FAKE,DC=DOMAIN,DC=com' –OldsDNS 192.168.9.9 –NewDNS 192.168.9.99



Get-ADComputer : An empty SearchBase is only supported while connected to a GlobalCatalog.
At C:\Users\olujan\Desktop\BatchModifyDNSConfiguration\BatchModifyDNSConfiguration\BatchModifyDNSConfiguration.ps1:57 char:12
+ $Servers = Get-ADComputer -SearchBase "$DistName" -Filter "*" | ForEa ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ADComputer], ArgumentException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.GetADComputer


I've tried with single and double quotes, re-order the switches... Feels like I'm making a rooking mistake. What am I doing wrong?
PowershellDNS

Avatar of undefined
Last Comment
footech
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Omar Lujan
Omar Lujan

ASKER

Thanks I knew it was a rookie mistake
Avatar of footech
footech
Flag of United States of America image

Really the only way to see it is to look at the code since there isn't any built-in help or examples.  Since the error mentions line 57, go there first.  The error also mentions an empty searchbase, and the command on line 57 references $DistName for the -searchbase parameter.  From there you go back to see how $DistName is defined.  That's pretty much the flow of how you begin to debug a problem.
DNS
DNS

The Domain Name System (DNS) is a hierarchical, globally distributed system responsible for associating the name of a computer, service or other resource into an IP address for connecting to the Internet or a private network. Most prominently, it translates domain names to the numerical IP addresses needed for the purpose of computer services and devices worldwide.

29K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo