How to execute logon and logoff scripts using Group Policy Objects (GPO) - Active Directory (AD)

Sdílet
Vložit
  • čas přidán 26. 08. 2024
  • Demonstration on how you can create and enforce logon and logoff scripts for clients connected to Windows Server 2022 using Group Policy Objects (GPO). This allow Administrators to push scripts across multiple clients based on their relationships to Organizational Units (OU) with Active Directory (AD).
    Force loading GPOs to clients:
    gpupdate /force
    This demonstration uses Windows Server 2022 server with Windows 10 and Windows 11 Professional clients. But the principles are same for Windows Server 2012 through 2022 (Windows Server 2022 / 2019 / 2016 / 2012). There are no GUI differences among most of the pervious versions of Windows Servers. The enforced GPO settings will work on Windows 11, 10 and previous versions of client Operating Systems connected to the domain Active Directory.
    -Intro to Group Policy Management: • Introduction to Group ...
    -Create Active Directory OUs and Users: • Create Active Director...
    -Install AD DS on Windows Server 2022 Core: • Install Active Directo...
    -Initial configs: • Windows Server 2022 Co...
    -Windows Server Admin playlist:
    • Windows Server Adminis...
    -Microsoft Windows playlist:
    • Microsoft Windows
    Track: WhileART Sessions Episode 02 | Waramathi (වරමාතී) Fusion
    Watch: • WhileART Sessions Epis...
    sanuja.com
    Co-producer:
    Manuja Senanayake
    #windowsserver2022 #AD #GPO #powershell #powershell7

Komentáře • 18

  • @user-tr1zt1mq7h
    @user-tr1zt1mq7h Před 5 měsíci +1

    Okay this may be the reason why my O365 isn't executing.. Login script wasn't set into that directory. It was in the same shared folder as the O365 setup.exe.

    • @suffer7845
      @suffer7845 Před 3 dny

      Did you figure this out? I'm trying to make a script now with GPO and Office Deployment Tool.

  • @timecop79
    @timecop79 Před 8 měsíci

    Good job, I'm working on something similar, I'm trying to add keyboard layouts for all users (French \Arabic) for exemple, the poilcy work fine with the powershell scripts but when I added it to mdt deployment it doesn't work, is there any other options to do it, thanks

  • @user-vi5by3lv9p
    @user-vi5by3lv9p Před 8 měsíci

    Thank you sir.

  • @DaniLearnsIT
    @DaniLearnsIT Před 11 měsíci +2

    What happens if you point the GPO to a script in a different location rather than the folder where you are pasting the script?

    • @NetITGeeks
      @NetITGeeks  Před 11 měsíci +1

      It is recommended that you use this specific location. But with PowerShell scripts and many other types of scripts, you can run scripts located anywhere in a network. You can have a PowerShell script for example where the main script is located in the server but pulling additional scripts from elsewhere. So, that is what I would do if I want to implement this with scripts located elsewhere. Have the main script in the location mentioned in this tutorial but pull additional scripts into it from elsewhere within that main script. This way it is also make it easier to manage and administer the server. In fact, lots of large companies I worked use that technique.

    • @DaniLearnsIT
      @DaniLearnsIT Před 11 měsíci

      @@NetITGeeks Thank you :)

  • @user-vd1fk2hk5k
    @user-vd1fk2hk5k Před rokem +1

    sir... i need help plz.... i need to run these commands on each pc/laptop on the network. so better to create a script for them all and deploy via gpo. so how to do it?
    - disconnect all mapped folders/drives
    - ipconfig /flushdns
    - ipconfig /release
    - ipconfig /renew
    - gpupdate /force
    - restart pc

    • @NetITGeeks
      @NetITGeeks  Před 11 měsíci +1

      I would recommend creating a PowerShell or bash script and then attaching it to a GPO. If I am trying to accomplish this, I would simply add this to logon script so the overhead is smaller.

    • @user-vd1fk2hk5k
      @user-vd1fk2hk5k Před 11 měsíci

      @@NetITGeeks how to write the script for these commands?

  • @thushanbasnayaka4799
    @thushanbasnayaka4799 Před 8 měsíci +1

    Does it works to windows server 2008 r2?

    • @NetITGeeks
      @NetITGeeks  Před 8 měsíci

      Yes, it should work on Windows Server 2008 R2 as well. This is a GPO in the AD so as long as your AD module is updated (via Windows updates), this should work).

  • @waffleMccoy
    @waffleMccoy Před 6 měsíci

    CAn it be done on command, without the users having to logoff and login again?

    • @NetITGeeks
      @NetITGeeks  Před 6 měsíci

      Most scripts can be run using gpupdate /force command on CMD and it will pull the GPOs and scripts. But some requires a logoff/logon or reboot.

  • @stephenvernon2431
    @stephenvernon2431 Před 9 měsíci

    What if you need to run PowerShell in administrator mode?

    • @NetITGeeks
      @NetITGeeks  Před 9 měsíci +1

      I believe the logon/logoff scripts can be written to launch in admin mode even if a client logs in. I would have to look into this because it is most likely a simple code you need to add to the top of the script, which I have no idea at the moment.

    • @stephenvernon2431
      @stephenvernon2431 Před 9 měsíci

      Thank you

    • @DangerMahs
      @DangerMahs Před 8 měsíci

      @@NetITGeeks Hello, were you able to find information to run the scripts in administrator mode?
      My script requires modifying a registry key and does not start due to lack of administrator mode on a domain.