Welcome › Forums › General PowerShell Q&A › set-dnsserverforwarder -using list of IP addresses
- This topic has 1 reply, 2 voices, and was last updated 1 month, 2 weeks ago by
Participant.
Viewing 1 reply thread
-
AuthorPosts
-
-
December 1, 2020 at 2:24 pm #275724
I have to make a mass change to a bunch of dns forwarders IP addresses. My issue is I’m importing a CSV of the server and IP addresses. When I run my code I get:
PowerShell1234[crayon-60081decd97bf768655588 inline="true" ]Set-DnsServerForwarder : Cannot process argument transformation on parameter 'IPAddress'. Cannot convert value"172.27.231.254, 172.27.254.68, 172.27.227.49, 172.28.5.47" to type "System.Net.IPAddress[]". Error: "Cannot convert value"172.27.231.254, 172.27.254.68, 172.27.227.49, 172.28.5.47" to type "System.Net.IPAddress". Error: "An invalid IP addresswas specified.""CODE:
PowerShell1234567891011[crayon-60081decd97c3789618201 inline="true" ]$newForwarders = import-csv -path C:\Temp\ADQueries\VA_DNSForwarders_new.csv$newforwarders | ForEach-Object {$IP = [IPAddress]$_.NewIP.Trim()write-host $_.name "and" $_.newipGet-DnsServerForwarder -ComputerName $_.name | select-object name,ipaddressSet-DnsServerForwarder -ComputerName $_.name -IPAddress $IPGet-DnsServerForwarder -ComputerName $_.name | select-object name,ipaddress}I added this as you can see above to convert the value but of course I have a string of multiple IP values. Any ideas how I resolve this? As now I’m getting:
PowerShell12[crayon-60081decd97c6610166095 inline="true" ]Cannot convert value "172.27.254.68,172.27.227.49,172.28.5.47" to type "System.Net.IPAddress". Error: "An invalid IPaddress was specified."List of data in csv:
PowerShell123[crayon-60081decd97c9866389166 inline="true" ]IPAddress,NewIP,Name"172.27.254.68, 172.26.1.59, 172.26.134.11","172.27.254.68,172.27.227.49,172.28.5.47",IAD0DC.domain.com"172.26.1.59, 172.26.134.11, 172.29.74.44","172.27.227.49, 172.28.5.47",CLE7DC.domain.com-
This topic was modified 1 month, 2 weeks ago by
lawson2312.
-
This topic was modified 1 month, 2 weeks ago by
lawson2312.
-
This topic was modified 1 month, 2 weeks ago by
-
December 2, 2020 at 11:56 am #276018
-
-
AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.