I'll preface this post by saying I am NOT a PowerShell expert by any stretch of the imagination, but I need to get this script done fairly quickly and would greatly appreciate some help.
Our environment has about 6 DHCP scopes at each site (about 125 sites). Each site has a dhcp server.
I need to write a script to change the DNS servers on all the scopes except for one.
All scope names are uniform, but they all have unique ranges.
Instead of having to plug in all the ScopeID variables for every scope using a different command (apparently, I also can't stack multiple ScopeID's in the same command) using the following:
Set-DhcpServerv4OptionValue -ComputerName "srv1234.blah.net" ,-ScopeID, 188.8.131.52, etc -DnsServer 123.456.789.1, etc
Is there a way to simply use scope names? Obviously, simply substituting -ScopeID for -Name isn't valid, since even though it's listed in the output of format-list, it's not a unique variable.
Or use a command like
Set-DhcpServerv4OptionValue -ComputerName "srv1234.blah.net" -DnsServer 123.456.789.1
But with an exclusion for the scope I don't want?