How to Assign Logon Scripts with a Group Policy

How to Assign Logon Scripts with a Group Policy

Logon scripts can be very handy when we need certain actions been done with a user logon such as mapping a network drive. This tutorial will show you how to assign a logon script using Group Policies.

In order to do that your account must have Domain Admin rights, delegated “edit GPO settings” rights or be an owner of the GPO.

There are four types of script you can use with Group Policy:

  • Logon scripts (User Configuration)
  • Logoff scripts (User Configuration)
  • Startup scripts (Computer Configuration)
  • Shutdown scripts (Computer Configuration)

In this example we will be focused on Logon Scripts.

Assigning Logon Scripts via Group Policy Management Console

  • Run Group Policy Management Console (GPMC.msc) on a domain workstation or server where it is installed.
  • In the left pane, expand your domain Forest -> Domains and then navigate to the domain where you want to assign a logon script.
  • Expand the domain name and then expand the Group Policy Objects.
  • Select the GPO or create a new one for assigning a script. Right-click GPO and select “Edit”.
Editing a Group Policy Object

• The window with Group Policy Management Editor (gpedit.msc) appears.
• Expand User Configuration -> Policies -> Windows Settings.
• Then select Scripts and double click «Logon».
• In the Logon window, click the Add… button.
• The “Add a Script” window appears:

• Type path to your script in the “Script Name:” field or browse to its location by clicking on “Browse…” button.
• In the “Script Parameters:” field, type any optional script parameters.
• Click “OK” to save the script settings and “OK” to close the “Logon Properties” window.
• Close the Group Policy Management Editor and link your policy to and organizational unit (OU) where you want logon scripts to run.
• To do that click on an organizational unit and then click on “Link an Existing GPO”.

  • • Choose the GPO we’ve just edited and click “OK”. After that right-click on the Organizational Unit and select “Update Group Policy”. In the appeared windows click on “Yes”.

Now all workstations in the OU will get our group policy with logon script and after reboot and user login the script will be executed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s