
To correctly run PowerShell scripts during computer startup, you need to configure the delay time before scripts launch using the policy in the Computer Configuration -> Administrative Templates -> System -> Group Policy section. Select the Startup policy, and go to the PowerShell Scripts tab in the next window. Suppose, we have to run the PowerShell script at a computer startup.
If you want to run the PowerShell script at a computer startup (to disable outdated protocols: NetBIOS and LLMNR, SMBv1, configure computer security settings, etc.) or before the computer shutdown, you need to go to the GPO section with the computer settings: Computer Configuration -> Policies -> Windows Settings -> Scripts (Startup / Shutdown).Ĭonfiguring PowerShell Startup Scripts with Group Policy. If you want to run a PS script when a user logon (logoff) to a computer (to configure user’s environment settings, programs, for example: you want to automatically generate an Outlook signature based on the AD user properties, adjust screensaver or Start layout 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 policy management console – GPMC.msc (Group Policy Management), create a new policy and link it to the desired Active Directory container (OU) with users or computers (you can use WMI GPO filters for fine policy targeting).
bat batch file as a parameter of the powershell.exe executable). Before Windows 7 and Windows Server 2008 R2, it was impossible to directly run PowerShell files from a GPO (it was necessary to call the.