
gpupdate >nul
gpupdate
command is used to update Group policies in Windows operating system Domain. There are different options to use with the gpupdate
but one of the most used option is /force
which will reapply all policy settings.
gpupdate
命令用于更新Windows操作系统域中的组策略。 gpupdate
可以使用不同的选项,但是最常用的选项之一是/force
,它将重新应用所有策略设置。
得到帮助 (Get Help)
Even “gpupdate” command provides very basic features we may need to get some help about the options. We can list help information by using /?
option like below. This will list options and option explanation of the “gpupdate” command.
甚至“ gpupdate”命令也提供了非常基本的功能,我们可能需要获得有关这些选项的帮助。 我们可以使用/?
列出帮助信息/?
如下所示的选项。 这将列出“ gpupdate”命令的选项和选项说明。
> gpupdate /?

仅强制 (Force Only)
We can force to reapply all group policy settings with the /force option. The default behavior of the /force option is only update changed policies.
我们可以使用/ force选项强制重新应用所有组策略设置。 / force选项的默认行为是仅更新更改的策略。
> gpupdate /force

As we can see from screenshot User and Computer policies are updated successfully.
从屏幕截图中可以看到,用户和计算机策略已成功更新。
仅更新用户策略 (Update Only User Policies)
By default all policies will be updated with the “gpupdate” command. If we want to update only the policies related with the user objects wen need to specify the /Target:User
options to the “gpupdate” command like below.
默认情况下,所有策略都将使用“ gpupdate”命令进行更新。 如果我们只想更新与用户对象相关的策略,则需要为“ gpupdate”命令指定/Target:User
选项,如下所示。
> gpupdate /Target:User
仅更新计算机策略(Update Only Computer Policies)
Alternatively, we can only update computer object-related policies with the option /Target:Computer
like below.
另外,我们只能使用选项/Target:Computer
来更新与计算机对象相关的策略,如下所示。
> gpupdate /Target:Computer
强制并重新启动 (Force and Reboot)
If we want to force and make the system restart or reboot we should provide the option /boot
next to the option /force
like below.
如果要强制并使系统重新启动或重新引导,则应在选项/force
旁边提供选项/boot
,如下所示。
> gpupdate /force /boot
强制和注销帐户 (Force and Logoff Account)
We can also log off from the current session or account after updating the group policy forcibly. We will provide the /logoff
option after the option /force
like below.
在强行更新组策略后,我们还可以从当前会话或帐户注销。 我们将在/force
选项之后提供/logoff
选项,如下所示。
> gpupdate /force /logoff
将超时设置为强制gpupdate (Set Timeout To Force gpupdate)
Updating group policy may take some time or run forever if there is a problem. This problem can be a network or domain-related problem. Especially in remote branches network problems are very popular. We can set a time that will stop the update if it is not completed. We call this a timeout and use /w
option and provide a time.
如果有问题,更新组策略可能会花费一些时间或永远运行。 此问题可能是与网络或域相关的问题。 尤其是在远程分支机构中,网络问题非常普遍。 我们可以设置一个时间,如果更新尚未完成,它将停止更新。 我们将此称为超时并使用/w
选项并提供时间。
In this example, we will wait for 120
seconds in order to complete a group policy update.
在此示例中,我们将等待120
秒以完成组策略更新。
> gpupdate /force /w:120
使用PowerShell强制gpupdate (Force gpupdate with PowerShell)
gpupdate
command can be used in PowerShell too. We can use -force
option like below with Invoke-GPUpdate
command.
gpupdate
命令也可以在PowerShell中使用。 我们可以在Invoke-GPUpdate
命令中使用如下所示的-force
选项。
PS> Invoke-GPUpdate -force
翻译自: https://www.poftut.com/how-to-run-gpupdate-force-on-windows/
gpupdate >nul