Script to change DNS

Guys,
We are changing the IP address of one our domain contoller which is also a DNS server. Need a script to change the dns server ip in about 70 servers, script should to change only the old ip address while the other 2 DNS addresses should remain as it
is.

You can try
http://superuser.com/questions/463096/change-dns-with-script
http://blogs.technet.com/b/heyscriptingguy/archive/2014/01/26/weekend-scripter-modify-dns-settings-via-windows-powershell.aspx
http://social.technet.microsoft.com/Forums/windowsserver/en-US/ed3f4c9e-1467-4795-b9d1-ae41937b8962/script-to-change-dns-servers-on-remote-server?forum=winserverpowershell
-Greg

Similar Messages

  • Script to Change DNS Servers on Remote Server

    I am new to powershell and I am trying to construct a script to change the DNS servers settings on a whole list of machines remotely. I have the list of machines that I want to change in a txt file. I have read several posts on this and tried several different
    methods but I cannot seem to get it to work. Here is my code, any help is much appreciated.
    $servers = Get-Content C:\PathToFile\computers.txt
    foreach($server in $servers)
        Write-Host "Connect to $server..."
        $nics = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $server -ErrorAction Inquire | Where{$_.IPEnabled -eq "TRUE"}
        $newDNS = "10.1.1.1","10.2.2.2"
        foreach($nic in $nics)
            Write-Host "`tExisting DNS Servers " $nic.DNSServerSearchOrder
            $x = $nic.SetDNSServerSearchOrder($newDNS)
            if($x.ReturnValue -eq 0)
                Write-Host "`tSuccessfully Changed DNS Servers on " $server
            else
                Write-Host "`tFailed to Change DNS Servers on " $server

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/28/use-powershell-to-configure-static-ip-and-dns-settings.aspx
    Ed Wilsons Blog.
    $computer = Get-Content C:\PathToFile\computers.txt
    $wmi = Get-WmiObject win32_networkadapterconfiguration  -computername "$computer" -filter "ipenabled = 'true'"
    $wmi.SetDNSServerSearchOrder("10.0.0.15", "255.255.255.0")
    I dont have the feasibility to check as of now. Please test and let me know.
    Thanks
    Azam
    Mark As an Answer if it answered your question or helpful if helped.

  • Powershell script to modify DNS not returning errors

    I've modified a script to make DNS changes given a name/IP combo from a CSV file and it seems to be working, but is not throwing any errors (which I had thought it would do, but doesn't)
    ## Directions:
    ## Script Requires DnsShell 0.4.4 http://dnsshell.codeplex.com/
    ## Script Uses Get-Dns and New-DnsRecord
    ## csv file must be in following format including the proper first line headers
    ## Name,IPAddress
    ## eample_a_record,127.0.0.1
    Write-Host "Enter Name the Path to the CSV File>"
    $CSV = read-host
    Write-Host "Enter Name the DNS Server>"
    $ServerName = read-host
    Write-Host "Enter the Domain example: domain.local>"
    $ForwardLookupZone = read-host
    $filename = "D_ERRLOG{0:yyyyMMdd-HHmm}.txt" -f (Get-Date) #error Log
    Write-Host "Enter The Reverse Domain Octet example 168.192 or 10 for 10.in-addr.arpa.>"
    $TReverseLookupZone = read-host
    $ReverseLookupZone = $TReverseLookupZone + ".in-addr.arpa."
    # Import CSV and create A record
    Import-Csv $CSV | ForEach-Object{
    $record = get-dnsrecord -name $_.name -recordtype A -zonename $forwardlookupzone -Server $ServerName
    if ($record.name) {get-dnsrecord -name $_.name -recordtype A -zonename $forwardlookupzone -Server $ServerName | Remove-DnsObject -force | out-file ./$filename -Append}
    New-DnsRecord -name $_.name -recordtype A -zonename $forwardlookupzone -IPaddress $_.IPAddress -Server $ServerName | out-file ./$filename -Append
    #create reverse record
    New-DnsRecord -Name $_.IPAddress -Hostname ($_.name + '.' + $forwardlookupzone) -Zonename $ReverseLookupZone -Type PTR -Server $ServerName | out-file ./$filename -Append
    Write-Host -foreground "yellow" "Any Errors will be in the file $filename"
    The out-file is blank, every time. I've even forced errors but it's still blank.
    Any ideas? 
    Thank you.
    [email protected]

    Hi,
    Just checking in to see if the suggestion was helpful. Please let us know if you would like further assistance.
    TechNet Subscriber Support
    If you are
    TechNet Subscription
    user and have any feedback on our support quality, please send your feedback
    here.
    Regards, Yan Li

  • Is it possible to script language change in OSX Lion ?

    I recently purchased a Disney game (Cars 2) from the App Store, which advertises being available in 5 languages. It seems now that the game has no in-app options to change language, but selects the language based on OSX settings (but otherwise the app doesn't use ANY of the GUI elements from the OS).
    My Mac's are all set up in English, in the account on which my kid plays the game doesn't have administrator rights (for good reasons). He doesn't master the English language enough and would like to play the game in dutch. On the other hand, when using Safari and other apps, he is used to the English user interface.
    Is it possible to create a script that changes the Finder language to Dutch, then forces Finder Quit, then launches the App, and after quitting the App reverses the Finder Change ? (or if not in one step, maybe in a number of subscripts), so that I can let my kid enjoy his game in dutch without me having to be present each time to change the system settings ?
    Thanks in advance.
    Philip

    Tom, thanks, this works perfectly. In older days, I have been a programmer on Mac (long before even the PowerMac days), and back then I would have used ResEdit to do something similar as what you suggested. Since those days are long gone, I was not sure if it was possible to change the resources of an app without extensive coding software, but the trick you just showed me seems to be the current-day equivalent of ResEdit ...
    Anyways, you saved our day ... thanks alot
    Philip

  • Powershell Script to change the default user Account picture for all users in windows 7 and 8

    Hello,
    Can some sone help me with PS script to change user account pictures of all user account in windows 7 and windows 8 ?
    I will deploy this through MDT TS as Custom TS after OSD.
    Shailendra
    Shailendra Dev

    Hello,
    Can some sone help me with PS script to change user account pictures of all user account in windows 7 and windows 8 ?
    I will deploy this through MDT TS as Custom TS after OSD.
    Shailendra
    Shailendra Dev
    The default user account picture is stored here.
    C:\programdata\Microsoft\User Account Pictures\user.bmp
    It should just be a matter have copying the picture you want to that location and over writing what is there.
    or....
    Computer Configuration\Administrative Templates\Control Panel\User Accounts\Apply the default user logon picture to all users
    You can also configure this by a registry setting;
     [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
      UseDefaultTile = 1
    The picture that you configure, will not be loaded until the user account will actually be created on the pc. Meaning the first time a >new< user will log on to a pc, they will have no picture shown at all using their login screen (this is default
    behavior). Same will occur if you enable the policy don't display last user name. However, once they log in the picture will be shown in the start menu, and if they lock their pc the image will also be shown

  • I have a BTHub4 - My iMac, iPhone, and children's iPads all connect to the internet no problem. I cannot get my 2 MacBook Pros or my partners MacBook Air to connect. Have tried diagnostics - says to change DNS but  it is correct.

    I have a BTHub4 - My iMac, iPhone, and children's iPads all connect to the internet no problem. I cannot get my 2 MacBook Pros or my partners MacBook Air to connect. Have tried diagnostics - says to change DNS but  it is correct. I have re-set both router and all laptops - no joy. They can all see the network but cannot connect.

    This is extraordinary. I have moved the router and also tried resetting it to its factory strings.  We have had this router for over a year and all our devices have always worked. Now all four laptops will not connect to the internet. Only one oMac and our phones and iPad.
    I have had far more devices running at once before but now all laptops are timing out on connection. Some say this iIP address is already being used but if I manually set to a slightly different IP address it does not help, noir if I manually set to the correct IP address. Why would all our laptops (four) suddenly be unable to connect?

  • Powershell script to change the a column value of all documents in a site.

    Hi,
    I need a powershell script to change the value of a column (a site column which has been added to all document libraries) in all documents in a site,
    For example: 
    -column 1 is a site column added to all libraries
    the value of column 1 of all documents under this site: http://intranet.doman/ex1 should be equal to V1
    the value of column 1 of all documents under this site: http://intranet.doman/ex2 should be equal to V2
    So, if I can write a powershell script to change the value of all documents in a site, I can modify it for different site that I have and run it for each of them individually,

    cls
    # Is dev version?
    $dev = $false
    # Configuration
    $termStore = "Managed Metadata Service"
    $group = "G1"
    $subjectMatterTermSetName = "Subject Matter"
    # Check if SharePoint Snapin is loaded
    if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
         Add-PSSnapin Microsoft.SharePoint.PowerShell
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Taxonomy") | Out-Null
    function GetTermStore($site, $termStore, $group, $termSet) {    
        $session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
        $termStore = $session.TermStores[$termStore]
        $group = $termStore.Groups[$group]
        $termSet = $group.TermSets[$termSet]
        return $termSet
    if($dev) {
        Write-Host "Running DEV version..."
        $webUrl = "http://Site1"   
        $libraryName = "L1"
        $subjectMatter = "C1"
    } else {
        $webUrl = Read-Host "Enter Site URL" 
        $libraryName = Read-Host "Enter Document Library name"
    $subjectMatter = Read-Host "Enter Subject Matter"
    try {
        $web = Get-SPWeb $webUrl
        $site = $web.Site
        $library = $web.Lists[$libraryName]
        $items = $library.GetItems()
        $subjectMatterTermSet = GetTermStore $site $termStore $group $subjectMatterTermSetName
        $subjectMatterTerm = $subjectMatterTermSet.GetTerms($subjectMatter,$true) | select -First 1
        foreach($item in $items) {
            if([string]::IsNullOrEmpty($item["Subject Matter"])) {     
                #Write-Host "Filename: $filename / Keywords: $keywords / Subject Matter: $subjectMatter / Document Type: $documentType"        
                Write-Host "Updating $($item["ows_FileLeafRef"])..."           
                # Set Subject Matter column
                $subjectMatterField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$item.Fields["Subject Matter"]
                $subjectMatterField.SetFieldValue($item,$subjectMatterTerm)
                # Update Item
                $item.SystemUpdate()
    catch
        $ErrorMessage = $_.Exception.Message
        Write-Host "Something went wrong. Error: $ErrorMessage" -ForegroundColor Red

  • [JS, CS3] a script to change language in all paragraph styles

    Hi,
    I made a script to change the language in all paragraph styles to "French", but when I run it I get the error: "Invalid request on root style". Could you please tell me what am I missing?
    myDoc = app.activeDocument;
    myStyles = myDoc.paragraphStyles;
    for (i = 0; i < myStyles.length; i++)
    myStyle = myStyles[i];
    myStyle.appliedLanguage = "French";

    Thanks a lot!
    The problem is solved
    Ola

  • In Firefox 2.0+ you can go to Advanced JavaScript Settings and check a box to allow scripts to change status bar text. How do I do this is Firefox 10.0.1?

    In Firefox 2.0+ you can go to Advanced JavaScript Settings and check a box to allow scripts to change status bar text. How do I do this is Firefox 10.0.1?

    Two items in the Advanced JavaScript window were removed as of the Firefox 4.0 version, but they are still available thru about:config .
    Type '''about:config''' in the URL bar and hit Enter. <br />
    ''If you see the warning, you can confirm that you want to access that page.''
    Filter = '''dom.disable_window_status_change''' = double-click to toggle to '''false''' to allow websites to mess with status text.

  • Scripts for changing the address of the user when they have been in the box for 6 months

    Scripts for changing the address of the user when they have been in the box for 6 months
    If users are in a folder for deactivated users and disabled users in Active Directory, and been there for 6 moths do: change email address in exchange to existing email address.old 
    Anyone have suggestions on how I can go about it?

    What is this "box"?  What is this "folder" you're asking about?  You'll likely get a better answer if you use standard terminology.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

  • Script to change language

    I need to find all cyrillic characters in a file and set their language to Russian. CS3 cannot find them with grep, so I reckon on doing them one at a time, can anyone help me with an Applescript line which would find X and set its language to Russian? The cyrillic characters in the font in question (Baskerville 10 by Storm) are unicode 0401 through 0491, I'm not sure if the script line needs to be of text or glyph type...
    Thanks!
    Andrew Brown
    (PS. I use the sample find-replace script a lot, but don't know how to adapt it to this purpose.)

    That works perfectly, thanks Peter ! -- AB
    On 17 Feb 2008, at 18:16, Peter Kahrel wrote:
    > A new message was posted by Peter Kahrel in
    >
    > InDesign Scripting --
    > Script to change language
    >
    > CS3 cannot find them with grep
    >
    > Try this: search for [\x{0401}-\x{0491}] and set Rusian in the
    > Change Format pane. That should doe what you want.

  • Bash script to change a string in /etc folder?

    I am wanting to create a script to change one of the values for the authorization file.   (See Article TS3287 in the KB)
    I assumed that I could use the sed command to do this, but I am getting an error when attempting to run.  Any ideas?
    Below is the code I wrote ...
    #!/bin/bash
    OLD="<string>The owner or any administrator can unlock the screensaver.</string>"
    NEW="<string>(Use SecurityAgent.) The owner or any administrator can unlock the screensaver.</string>"
    DPATH="/etc/authorization"
    BPATH="/etc"
    TFILE="/tmp/out.tmp.$$"
    [ ! -d $BPATH ] && mkdir -p $BPATH || :
    for f in $DPATH
    do
      if [ -f $f -a -r $f ]; then
        /bin/cp -f $f $BPATH
       sed "s/$OLD/$NEW/g" "$f" > $TFILE && mv $TFILE "$f"
      else
       echo "Error: Cannot read $f"
      fi
    done
    /bin/rm $TFILE

    You do the testing- this script should work->
    #!/bin/bash
    #This script needs to run as root
    ROOT_UID=0
    if [[ $UID -ne $ROOT_UID ]]; then
    echo "YOU MUST BE ROOT TO RUN THIS SCRIPT"
    exit 1
    fi
    OLD="<string>The owner or any administrator can unlock the screensaver.<\/string>"
    NEW="<string>(Use SecurityAgent.) The owner or any administrator can unlock the screensaver.<\/string>"
    cp /private/etc/authorization /tmp/auth.tmp
    sed "s/$OLD/$NEW/" /tmp/auth.tmp > /tmp/authorization
    mv /private/etc/authorization /private/etc/authorization.previous
    mv /tmp/authorization /private/etc/authorization
    rm /tmp/auth.tmp

  • Pros and cons of changing DNS servers?

    Hello guys, First of all I am a non technical person related to DNS servers. So I want to know what are the pros and cons if you change your DNS servers?
    I wanted to access Netflix but its not yet available in my country so I came across http://unotelly.com/ . They provide a method to access but by changing DNS. Can someone guide should I do it? What are the pros and cons? Thank you

    The DNS is what translates in and outgoing URLs to your local domain server. Changing it may have no adverse effect. It could result in faster or slower translations, but you may not even notice either. However, if it does not work properly, then you will not get web sites in your browser until you revert back to a DNS that you know works or delete all added DNS entries which returns to the system default.

  • Urgent:How to modify a script without changing the print programme

    Hi all,
    Can any body pls tell me <b>How to modify a script without changing the print programme</b>
    Give m esome real time examples.
    Good points willbe rewarded
    Thanks

    Hi
    You can write a external Subroutine to fetch the extra data into the script program
    see the following sample code
    How to call a subroutine form SAPscripts
    The Form :
    /:PERFORM CDE_CENT IN PROGRAM ZKRPMM_PERFORM_Z1MEDRUCK
    /:USING &EKKO-EBELN&
    /:CHANGING &CDECENT&
    /:ENDPERFORM
    The report :
    REPORT zkrpmm_perform_z1medruck .
    DATA : BEGIN OF it_input_table OCCURS 10.
    INCLUDE STRUCTURE itcsy.
    DATA : END OF it_input_table.
    déclaration de la table output_table contenant les
    variables exportées
    DATA : BEGIN OF it_output_table OCCURS 0.
    INCLUDE STRUCTURE itcsy.
    DATA : END OF it_output_table.
    DATA : w_ebeln LIKE ekko-ebeln,
    w_vbeln LIKE vbak-vbeln,
    w_zcdffa LIKE vbak-zcdffa.
    FORM CDE_CENT
    FORM cde_cent TABLES input output.
    it_input_table[] = input[].
    it_output_table[] = output[].
    READ TABLE it_input_table INDEX 1.
    MOVE it_input_table-value TO w_ebeln.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = w_ebeln
    IMPORTING
    output = w_ebeln.
    SELECT SINGLE zcdffa FROM ekko
    INTO w_zcdffa
    WHERE ebeln = w_ebeln.
    it_output_table-name = 'CDECENT'.
    MOVE w_zcdffa TO it_output_table-value.
    MODIFY it_output_table INDEX 1.
    output[] = it_output_table[].
    ENDFORM.
    COPING SCRIPT
    There are some Standard Sap Scripts in SAP. We cant directly execute them in scripts we have to use some T-codes and by giving some input to the required fields we can see the output printform.
    I will show one example. There are some Standard Sap Scripts such as MEDRUCK which is a standard Sap Script for Purchase Order and RVINVOICE01 for billing and so on...
    To see oupt of MEDRUCK go to T-code ME9F give purchase order number and execute select one number and click on dislplay messages button on application tool bar you can find the print form of MEDRUCK.
    You cannot change the Standard Sap Scripts but you can use Standard Sap Scripts and Copy them to userdefined Script and can make changes to them and replace standard Sap Script with usedefind script.
    Ex: Go to SE71,
    on menu bar u find Utilities->copy from Client. click on it u ll find new screen showing
    Form name:
    Source Clinet:
    Target Form:
    give Form name as usedefined form name EX: ZFORM1
    Source client as 000 and
    Target form as MEDRUCK.
    execute.
    Now, the standard from MEDRUCK is copyied to your form ZFORM1.
    NOW, go to SE71 and give form name as ZFORM1 and do some changes to the form such as adding logo any thing. save and Activate.
    Now, you have done changes to the Form ZFORM1 and u have to replace your form with standard SAP Script.
    Go to NACE Transaction.
    on Applications select EF for purchase order and click Output types button on application tool bar.
    now select NEU as output types dobule click on Processing Routines.
    now click on Change option on application tool bar and on right side u find MEDRUCK in form place replace MEDRUCK with ZFORM1 and SAVE.
    go back twice and now go to T-code ME9F give the purchase order number and execute and select one option and click on display messges button .
    you will find the changes that you have done in ZFORM1. so we cant chage the standard Sap Scripts by copying the Standard Sap Scripts we can chage and replace with our forms
    Refer
    https://forums.sdn.sap.com/click.jspa?searchID=4089895&messageID=3239299
    Regards
    Message was edited by:
            Kiran Sure(skk)

  • Script to Change swatch CMYK values

    Are there any scripts available to change CMYK values of swatches for files in CS3?
    I have hundreds, probably thousands of Illustrator EPS files that use swatches all drawn from a total palette of maybe 50 colours.
    Each colour is named and has a corresponding CMYK value.
    I want to update the CMYK values for all ~50 colours that appears across all these documents. Is there some way I can simply change the CMYK spec of the swatches used by each of these documents by not having to manually open and change the colours etc?
    Even a script would be good that could batch process the files?
    For example:
    File contains a swatch as a named colour like:
    Fire Red spec'd as 0, 96, 99, 0
    I want to automate changing the CMYK values for all files containing Fire Red to, say, 0, 98, 99, 0
    Any ideas? I have searched Google for a couple of days.
    Edit: the flavour here is Illustrator for CS3 - both Win and Mac.

    I understand EXACTLY what you mean as it's the same thing I need to do, and will probably need to do on future occasions.
    Did you get anywhere with this problem?
    I have designed a scheme for a textbook I am illustrating (this is what I do for a living and have been doing so for well over a decade using Illustrator).
    All colours used in every illustration are based on 7 CMYK Global swatches, usually 100% tints but also 50% 75% and others when required.
    Anyway I have done 100 illustrations already based on my template when I realize I'm going to have to darken the green by +10% cyan.
    What I need is a script to change the definition of my global 'green' swatch in every document from 100Y 30C to 100Y 40C.
    Actions won't do it.
    Any suggestions?

Maybe you are looking for

  • Can't add files from the internet

    no matter how i try to add this file i got off the internet, it won't go into the library. i tried putting it in a new folder and dragging the file in and adding a new file and importing it, and nothing worked! it really frustrates me because i reall

  • Flat file load issue-Urgent

    Hello I'm trying to load a master data infoobject with a flat file and getting errors. The infoobject ZCOLLECT_DATE has two fields - ZQUARTER and ZCOLLECTDATE ZCOLLECT_DATE is of Data type NUMC, Length 5, conversion routine PERI5 and Output length 6

  • Timestamped document with expired certificate - not validating

    Hi, I have a document that was timestamped and certified on 2010/11/23 15:32:16 -03'00'. The timestamp certificate is still valid, but the certifier's certificate expired on 2010/12/11 07:00:00 -03'00'. The Reader can't validate this certificate, eve

  • Looking for ideas/discussion on "Best Approach"

    I have to create a form using JSP/Servlets with the following form fields Customer Details Customer ID Name Street City Country Product Details Product ID Product Name Manufacturer Product Code Country of Production //Where the product was manufactur

  • GS-08: Distributing Stage contents to layers | Learn Flash Professional CS5 & CS5.5 | Adobe TV

    Layers allow you to organize the contents of the Stage from front to back. Objects on a layer can be shown, hidden, edited, or moved at the same time. Move objects into layers by using the Distribute To Layers command. http://adobe.ly/zreqPV