I’ve seen a lot of people wanting to do a GPUpdate when a task sequence has finished and before the computer reboots so that it will have a certain policy or setting in place the first time the machine boots.
This is what I do in my task sequence to achieve this result.
Step 1
Open your task sequence and create a New Group. Name your group whatever you like and give it a description. I called mine Enable Group Policy.
Step 2
Add 4 Run Command Line steps to your task sequence under your new group. Name the first one and give it a description. Paste the following line in the command line section.
cmd /c reg add “HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions\{827D319E-6EAC-11D2-A4EA-00C04F79F83A}” /v MaxNoGPOListChangesInterval /t REG_DWORD /d 960 /f
Step 3
Go to your next command line step give it a name, a description, and paste the following in the command section.
powershell.exe -executionpolicy bypass -command “stop-service gpsvc -force”
Step 4
Go to your next command line step give it a name, a description, and paste the following in the command section.
powershell.exe -executionpolicy bypass -command “start-service gpsvc”
Step 5
Go to your last command line step give it a name, a description, and paste the following in the command section.
gpupdate /force
Your gpupdate will now run and your policies will be ready on the next reboot!
Too much trouble? Just want GPUpdate to run on the next reboot? Ok then. Just add a Run Command Line and the end of your task sequence before any reboot command and paste the following.
c:\windows\system32\reg.exe add “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce” /v GPupdate /d “C:\windows\system32\gpupdate.exe” /f
On the next reboot the Gpupdate will occur.