locked
Script for XP-SP3 machines through Windows 2008 R2 group policy. RRS feed

  • Question

  • Hi all,

    I've no knowledge of scripting, so could someone please help me put the following commands to start upon machine start-up (the first one should execute first then the second one):

    netsh interface ip set address "Local Area Connection" dhcp

    netsh interface ip set DNS "Local Area Connection" dhcp



    The above two commands should switch the XP-SP3 machines from static IP to DHCP.
    Tuesday, October 20, 2009 11:13 AM

Answers

  • Hai,

    Check the steps
    1. Copy the following lines to a notepad

    REM Start Script
    netsh interface ip set address "Local Area Connection" dhcp
    netsh interface ip set DNS "Local Area Connection" dhcp
    :end
    REM End script

    2. Save it in an appropriate name (for example: logon.bat, logon.cmd, logon.vbs, etc.). The script can use ANY name with the right file extension type
    3. copy the file to %SystemRoot%\SYSVOL\sysvol\<domain DNS name>\Policies\{GUID}\User\Scripts\Logon

    If you wish to assign script to more than one user, you will need to create as many logon scripts as you want, and then add them in the right order in the right GPO

    If you choose to apply on all the users in the domain, you must create a Group Policy Object (or GPO) and link it to the ENTIRE domain. If you choose to apply the script ONLY to a SPECIFIC SET of users, you must place all the users in one OU (Organization Unit) in Active Directory Users and Computers, and link the GPO to that OU.

    In order to assign the GPO and edit it, we'll use a tool called Group Policy Management console, or GPMC in short. This tool is not installed by default in Windows Server 2003, and neither is it installed by default in Windows Server 2008. In Windows Server 2008, GPMC is considered to be a "Feature", and you must install it before being able to use it.

    4. Open Group Policy Management Console from the Administrative Tools folder (or gpmc.msc from RUN).

    5.  If you decided to apply the script to ALL THE DOMAIN USERS, expand the domain tree, locate the domain name. Right-click the domain name and select Create and Link a GPO Here. If you decided to apply the script to ONLY a SPECIFIC SET of users, expand the domain tree, locate the OU where the users from are located. Right-click the OU and select Create and Link a GPO Here.

    6. In the New GPO window, give the new GPO a descriptive name, such as "Test Logon Script GPO". Click Ok.


    7. Right-click the new GPO and select Edit.

    8. In the Group Policy Management Editor window, expand User Configuration > Policies > Windows Settings > Scripts.

    9. Double-click Logon in the right-hand pane.

    10. In the Logon Properties window, click Show Files.

    11. A window will open. The path will be a folder similar to the following: \\domain.com\SYSVOL\<domain DNS name>\Policies\{E4A62379-8423-4654-8DB6-01FB8F58582D}\User\Scripts\Logon. Paste the logon script you've created there.

    12. Back in the Logon Properties window, click Add.

    13. In the Add a Script window, click Browse and you will see the logon script pasted in a previous step.  Click Ok.

    14. Back in the Logon Properties window, see if the logon script is listed, and if it is, click Ok

    15. Close the Group Policy Management Editor window.

    16. Close the GPMC window.

    17. On one of the computers that is part of the domain, logoff the specific user account.

    18. Logon and test whether it is working properly

    Regards from www.windowsadmin.info


    ManuPhilip
    • Marked as answer by CHQM Wednesday, October 21, 2009 5:48 AM
    Tuesday, October 20, 2009 4:26 PM

All replies

  • Hai,

    Check the steps
    1. Copy the following lines to a notepad

    REM Start Script
    netsh interface ip set address "Local Area Connection" dhcp
    netsh interface ip set DNS "Local Area Connection" dhcp
    :end
    REM End script

    2. Save it in an appropriate name (for example: logon.bat, logon.cmd, logon.vbs, etc.). The script can use ANY name with the right file extension type
    3. copy the file to %SystemRoot%\SYSVOL\sysvol\<domain DNS name>\Policies\{GUID}\User\Scripts\Logon

    If you wish to assign script to more than one user, you will need to create as many logon scripts as you want, and then add them in the right order in the right GPO

    If you choose to apply on all the users in the domain, you must create a Group Policy Object (or GPO) and link it to the ENTIRE domain. If you choose to apply the script ONLY to a SPECIFIC SET of users, you must place all the users in one OU (Organization Unit) in Active Directory Users and Computers, and link the GPO to that OU.

    In order to assign the GPO and edit it, we'll use a tool called Group Policy Management console, or GPMC in short. This tool is not installed by default in Windows Server 2003, and neither is it installed by default in Windows Server 2008. In Windows Server 2008, GPMC is considered to be a "Feature", and you must install it before being able to use it.

    4. Open Group Policy Management Console from the Administrative Tools folder (or gpmc.msc from RUN).

    5.  If you decided to apply the script to ALL THE DOMAIN USERS, expand the domain tree, locate the domain name. Right-click the domain name and select Create and Link a GPO Here. If you decided to apply the script to ONLY a SPECIFIC SET of users, expand the domain tree, locate the OU where the users from are located. Right-click the OU and select Create and Link a GPO Here.

    6. In the New GPO window, give the new GPO a descriptive name, such as "Test Logon Script GPO". Click Ok.


    7. Right-click the new GPO and select Edit.

    8. In the Group Policy Management Editor window, expand User Configuration > Policies > Windows Settings > Scripts.

    9. Double-click Logon in the right-hand pane.

    10. In the Logon Properties window, click Show Files.

    11. A window will open. The path will be a folder similar to the following: \\domain.com\SYSVOL\<domain DNS name>\Policies\{E4A62379-8423-4654-8DB6-01FB8F58582D}\User\Scripts\Logon. Paste the logon script you've created there.

    12. Back in the Logon Properties window, click Add.

    13. In the Add a Script window, click Browse and you will see the logon script pasted in a previous step.  Click Ok.

    14. Back in the Logon Properties window, see if the logon script is listed, and if it is, click Ok

    15. Close the Group Policy Management Editor window.

    16. Close the GPMC window.

    17. On one of the computers that is part of the domain, logoff the specific user account.

    18. Logon and test whether it is working properly

    Regards from www.windowsadmin.info


    ManuPhilip
    • Marked as answer by CHQM Wednesday, October 21, 2009 5:48 AM
    Tuesday, October 20, 2009 4:26 PM
  • Hi,

    netsh interface ip set DNS "Local Area Connection" dhcp not working.Kindly help 

    Tuesday, February 2, 2016 10:42 AM