How to Configure Logon and Logoff Scripts In Group Policy And Windows Server 2016

In this blog post, I’ll show you how to configure PowerShell Logon and Logoff Scripts In Group Policy running on Windows Server 2016 Directory Infrastructure.

PowerShell Logon\Logoff Scripts

Windows PowerShell Logon and Logoff scripts were first introduced with Windows Server 2008 R2 however many organization couldn’t take advantage of them because they were not supported on Windows XP.

A few years forward and you will not find XP or Windows 7 machines in enterprises and now using PowerShell Scripts for logon \ logoff is much easier because PowerShell is fully integrated into to Window 10.

With Windows Server 2016 and Group Policy there are many things you can do without using Logon Scripts but sometimes you might need to do something very specific that will require PowerShell.

Get Started

To configure Logon Script, I’ll use the Group Policy Management console and edit a GPO called Logon

I’ll edit my Group Policy by going to User Configuration -> Windows Settings -> Scripts -> Logon

Next, I’ll select the second tab (PowerShell Scripts) and click add to add my script.

Note: Please save the script to the SYSVOL folder on you Domain which will also be replicated to all DCs and will be available to all users

Below, you will see the location of my Script

For this example, I’ve created a script that will create a folder under the C:\ with a random number between 1 – 100

I’ll also select Run Windows PowerShell Scripts first

Now, that all the configuration has been done, next time I logon to the machine I’ll see a new folder with a random number.


If you need to configure logon scripts In Group Policy, I recommend you use PowerShell script, If you follow this post you will find easy to configure and manage.