Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Need help with this script.

$
0
0

Here is the complete code

[CmdletBinding()]
param(

    [parameter(Mandatory=$True,HelpMessage="The zone name that needs to be updated with the new Master IP's")]
    [string]$Zonename,

    [parameter(Mandatory=$True,HelpMessage="New Master IP Address")]
    [string[]]$MasterIP

    )

$serverlist = "c:\temp\serverlist.txt"

$results = "E:\$($Zonename).txt"

foreach ($server in $serverlist)

{
   write-host $server being updated -foreground yellow
   write "$server is being updated" | Out-File -Append $results
   dnscmd $server /zoneresetmasters $zonename $MasterIP | Out-File -Append $results
   $zoneinfo = dnscmd $server /zoneinfo $zone /masterservers
   if ($zoneinfo -match "$MasterIP" -and "$MasterIP")
   {
   write-host $server Masters updated -foreground green
   write "$server has been updated successfully" | Out-File -Append $results
   write "" | Out-File -Append $results
   }
   else
   {
   write-host Could not update masters on $server -foreground red
   write "Could not update masters on $server" | Out-File -Append $results
   write "" | Out-File -Append $results
   }
}


How do I make the $MasterIP seperated by a space in for each IP in this line?
dnscmd $server /zoneresetmasters $zonename $MasterIP

Example: dnscmd server01 /zoneresermasters test.local 10.10.10.1 10.20.20.40 10.30.30.40 10.50.50.40 

And how do I get $MasterIP to be seperated by -and for each IP in this line?
if ($zoneinfo -match "$MasterIP" -and "$MasterIP")

Example: if ($zoneinfo -match "10.10.10.1" -and "10.20.20.40" -and "10.30.30.40" -and "10.50.50.40")

Note: The number of IP addresses in $MasterIP may wary from the above example.


99upgrade


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>