Created
May 10, 2016 16:38
-
-
Save natemccurdy/d787321aa335aad22491beb2e89d8d25 to your computer and use it in GitHub Desktop.
Windows DNS registry entry generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build a registry value string for setting DNS servers on windows | |
$dns_servers = [ '1.1.1.1', '2.2.2.2', '3.3.3.3' ] | |
$suffixes = [ '0x09', '0x0a' ] | |
# Generate an array that has 0x09 after the first server, and | |
# 0x0a after all the other servers. | |
$array = $dns_servers.map |$index, $server| { | |
if $index == 0 { | |
"${server},${suffixes[0]}" | |
} else { | |
"${server},${suffixes[1]}" | |
} | |
} | |
# Create a string from the array that is separated by spaces. | |
$full_string = join($array, ' ') | |
# Show the output | |
notice($full_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment