gpupdate >nul_如何在Windows上运行gpupdate / force?

本文详细介绍了如何在Windows操作系统中使用不同选项执行gpupdate命令,包括仅强制更新、仅更新用户策略、仅更新计算机策略、强制重新启动、强制注销以及设置超时。还涵盖了如何通过PowerShell强制执行gpupdate。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

gpupdate >nul

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
Force Only
Force Only
仅强制

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选项并提供时间。

LEARN MORE  What Is LDAP Protocol Port Number? Compare LDAP Ports 389 vs 636
了解更多LDAP协议端口号是什么? 比较LDAP端口389和636

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值