Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Created May 10, 2016 16:38
Show Gist options
  • Save natemccurdy/d787321aa335aad22491beb2e89d8d25 to your computer and use it in GitHub Desktop.
Save natemccurdy/d787321aa335aad22491beb2e89d8d25 to your computer and use it in GitHub Desktop.
Windows DNS registry entry generation
# 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