How to get logon scripts distributed by GPO in local domain to run

Jasper Vandenbrande 20 Reputation points
2024-01-29T10:24:15.6566667+00:00

Hi, I am fairly new to sysadmin so any tips are welcome.

I am trying to deploy a logon script for Password notifications.
As a first step I made a testing script to run:

[system.Reflection.Assembly]:: LoadwithpartialName('System.windows.Forms') [system.windows.Forms.Messagebox]:: Show('Logon script runnin...' , 'WARNING') ping -n 10 10.170.4.52 I linked it to OU 'X'. OU 'X' contains my low level account. I am just trying to figure out how to run a script on logon in our environment.
Firstly I stored the script in a C:\tmp folder I created for testing purposes. This didn't work, I temporarily granted all domain users and pc's access to that folder. It didn't work.

Then I looked moor online and found out scripts are supposed to be in a folder in sysvol. something of this format:
\servername\SysVol\doamin\Policies{F3E42D53-EBE0-49F7-8780-199C13D4B880}\User\Scripts\Logon

I update the GPO, I do gpupdat/force on the host computer.
Nothing happens, no script runs.

I have little experience with scripts and running them through GPO's
So please if you have ideas on how to solve this issue. Even a link to more documentation I failed to find would be a lifesaver.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,822 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,884 questions
0 comments No comments
{count} votes

Accepted answer
  1. Daisy Zhou 31,776 Reputation points Microsoft External Staff
    2024-01-30T06:56:44.76+00:00

    Hello Jasper Vandenbrande, Thank you for posting in Q&A forum. The login script should be stored in the sysvol file. A SYSVOL is a shared folder that stores a copy of a domain's public file servers, which are replicated among all domain controllers in the domain. The sysvol folder is created when AD is installed, and it is used to store information such as GPO and Script. At the same time, the information stored in the sysvol folder is copied to all DCs in the domain. For more information about sysvol files, please refer to the Active Directory: Active Directory: SYSVOL and NETLOGON | Microsoft Learn. If you implement a boot script and apply startup script to domain computer, the script file needs to be stored in IP or hostname\sysvol\domain name\Policies\unique ID\Machine\Startup. In your case, you want to implement a login script and apply logon script to domain users, the script file needs to be placed in IP or hostname\sysvol\domain name\Policies\unique ID\USER\Scripts\Logon You can try the steps below:
    1.Create an OU and put user objects into this OU.
    2.Create one GPO and you can rename this GPO as logon script. 3.Put the this command line or Power Shell script file to this folder below: \domain.com\SYSVOL\domain.com\Policies{5EE96627-35BD-434C-9C6A-4AE328E7D13A}\User\Scripts\Logon 4.Edit this GPO as below. Navigate to User Configuration Policies\Windows Settings\Scripts (Logon/Logoff) User's image

    Right click Logon and select the logon script under the path \domain.com\SYSVOL\domain.com\Policies{5EE96627-35BD-434C-9C6A-4AE328E7D13A}\User\Scripts\Logon User's image

    5.If the specific users logon, then this user will apply the logon GPO. Please check out the links below: Working with startup, shutdown, logon, and logoff scripts using the Local Group Policy Editor | Microsoft Learn. For more information, you can also check the following link for details: Running PowerShell Startup (Logon) Scripts Using GPO | Windows OS Hub (woshub.com). I hope the information above is helpful. If you have any question or concern, please feel free to let us know. I hope the information above is helpful. If you have any question or concern, please feel free to let us know. Best Regards,
    Daisy Zhou If the Answer is helpful, please click "Accept Answer" and upvote it.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.