Skip to content

Instantly share code, notes, and snippets.

@weeyin83
Created March 26, 2021 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weeyin83/7d045e6ddfd413a6adc20186a977069d to your computer and use it in GitHub Desktop.
Save weeyin83/7d045e6ddfd413a6adc20186a977069d to your computer and use it in GitHub Desktop.
#Declare script to be run on remote server
$scriptblock = {param($zones,$dns_ip1,$dns_srv2,$z,$dns_srv3) Add-DnsServerSecondaryZone -MasterServers $dns_ip1 -Name $z -ZoneFile $z".dns"}
#Collects Credentials to connect to the remote server
$username = Read-Host -Prompt "Enter the username for the account"
Read-host -Prompt "enter password" -assecurestring | convertfrom-securestring | out-file C:\cred.txt
$password = get-content C:\cred.txt | convertto-securestring $credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist "$username",$password
# This line of Powershell loops round using the inputs and creates the primary copy of the non-integrated DNS zones on the first server
#This stage creates the non integrated zones using the first server as the primary server
$zones | foreach-object {Add-DnsServerPrimaryZone -ComputerName $dns_srv1 -Name $_ -DynamicUpdate None -ZoneFile $_".dns"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment