LingfeiWang-6262 avatar image
0 Votes"
LingfeiWang-6262 asked LingfeiWang-6262 commented

Assign a logon/logoff script to a GPO by using PowerShell

I can assign a script to a GPO by using Group Policy Management and Group Policy Management Editor, and i can use PowerShell to create a new GPO, and link it to an OU, setting the policy by using cmdlet Set-GPRegistryValue. But I cannot find a way to assign a script to logon/logoff in the GPO.

I had tried to create the directory \\domain\sysvol\domain\gp-guid\User\Scripts\Logon, copy the script into it, and then create the scripts.ini file under the User\Scripts. After this, you can see the configuration in Group Policy Management Editor. However, this configuration is not showed in the "Setting" tab page of the GPO in Group Policy Management. Moreover, it is not applied to the target users.

So, my question is how to assign a script to GPO by using PowerShell, or any other CLI tools?

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


I tried modifying the scripts.ini file and refreshed the gpo in Group Policy Management then the script was listed in the "Setting" tab as expected. Can you help to check the content of scripts.ini? On my side it's like this


0 Votes 0 ·


Thanks for the reply.

The content of my ini file is like this:

And i had tried to change the file into many different formats, such as ANSI, UNICODE, UTF-8, etc.
But there is no lucky.
BTW, the logon script is the only thing in the group policy object for user configuration, all others are for computer configuration.

0 Votes 0 ·
image.png (13.2 KiB)
image.png (57.9 KiB)


I think your steps were not the same with mine.
You midified an existing scripts.ini file, but i created a scripts.ini file for a GPO.
If one script is added by Group Policy Management Editor, then, the change of scripts.ini file would be shown in the setting tab.
There seems be an switch to indicate whethere the GPO has a script configuration. If you add the script via Editor, the switch will be turned on.
But if you create the scripts.ini by yourself, the switch will be not touched, then this configuration will be not shown on the settings tab.

0 Votes 0 ·

0 Answers