
If you want to run a script from a different shared folder, or if you still have Windows 7 or Windows Server 2008R2 clients on your network, you need to configure the PowerShell script execution policy.īy default, Windows security settings do not allow running PowerShell scripts. This means that PowerShell Script Execution Policy settings are ignored. On Windows Server 2012R2 and Windows 8.1 and newer, PowerShell scripts in GPO are run from the NetLogon directory in the Bypass mode. This is usually enough time to initialize the Windows networking stack. After enabling this policy, your computer will wait 60 seconds for network availability notifications before running your startup scripts. You can try starting from 60 seconds here. If your PowerShell script uses Windows networking, you need to enable the “ Specify startup policy processing wait time” option for some GPOs (Computer Configuration -> Policies -> Administrative Templates -> System -> Group Policy). Select the Startup policy, and go to the PowerShell Scripts tab. Suppose, we have to run the PowerShell script at a computer startup.
How to Run PowerShell Scripts on Windows Startup with Group Policy?
If you want to run the PowerShell script at a computer startup (to disable legacy protocols: NetBIOS and LLMNR, SMBv1, configure computer security settings, etc.) or prior to the computer shutdown, you need to go to the GPO section with the computer settings: Computer Configuration -> Policies -> Windows Settings -> Scripts (Startup / Shutdown). If you want to run a PS script when a user logon (logoff) to a computer (to configure the user’s environment settings, or programs: for example, you want to automatically generate an Outlook signature based on the AD user properties, customize screensaver or Start screen settings), you need to go to the GPO section: User Configuration -> Policies -> Windows Settings -> Scripts (Logon / Logoff). You must select a GPO section to run the PowerShell script, depending on when you want to execute your PS1 script: Run the Domain Group Policy Management console ( GPMC.msc), create a new policy (GPO), and assign it to the target Active Directory container (OU) with users or computers (you can use WMI GPO filters for fine policy targeting). Run Windows PowerShell Script at User Logon/Logoff. How to Run PowerShell Scripts on Windows Startup with Group Policy?.