9.8. Assigning Logon/Logoff and Startup/Shutdown Scripts in a GPO
Problem
You want to assign either user logon/logoff scripts or computer startup/shutdown scripts in a GPO.
Solution
Using a graphical user interface
Open the GPMC snap-in.
In the left pane, expand the Forest container, expand the Domains container, browse to the domain of the target GPO, and expand the Group Policy Objects container.
Right-click on the target GPO and select Edit. This will bring up the Group Policy Object Editor.
If you want to assign a computer startup or shutdown script, browse to Computer Configuration → Windows Settings → Scripts. If you want to assign a user logon or logoff script, browse to User Computer → Windows Settings → Scripts.
In the right pane, double-click on the type of script you want to add.
Click the Add button.
Select the script by typing the name of it in or browsing to its location.
Optionally type any script parameters in the Script Parameters field.
Click OK twice.
Discussion
When you assign a script in a GPO, you can either reference a script that is stored locally on the domain controller somewhere under the NETLOGON share or a UNC path to a remote fileserver.
The logon script can also be set as an attribute of the user object
(scriptPath
). This is provided as legacy support
for users migrated from NT 4.0 domains. You should choose either one
method of specifying the logon script or the other, but not both, as
this will cause the logon script to run
twice.
Get Active Directory Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.