Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Windows PowerShell的组策略cmdlet获取/设置/更新注册表值?_Powershell_Windows Server_Cmdlets_Group Policy - Fatal编程技术网

如何通过Windows PowerShell的组策略cmdlet获取/设置/更新注册表值?

如何通过Windows PowerShell的组策略cmdlet获取/设置/更新注册表值?,powershell,windows-server,cmdlets,group-policy,Powershell,Windows Server,Cmdlets,Group Policy,我已经手动配置了EventForwarding,但我不知道是否可以通过编程实现,我遇到了一个解决方案,它似乎就是解决方案。下面是我试图在下图中手动配置的内容 运行Get-GPO-allcmdlet时,我没有看到任何与事件转发相关的GPO。但是,当我使用XML文件的指定路径运行Get-GPResultantSetTofPolicy时,我看到了事件转发订阅管理器的配置 问题1:Get GPO-all结果中为什么没有显示事件转发策略 问题2:如何找到我需要的策略的GUID,以便我可以使用?除了提供密

我已经手动配置了EventForwarding,但我不知道是否可以通过编程实现,我遇到了一个解决方案,它似乎就是解决方案。下面是我试图在下图中手动配置的内容

运行Get-GPO-allcmdlet时,我没有看到任何与事件转发相关的GPO。但是,当我使用XML文件的指定路径运行Get-GPResultantSetTofPolicy时,我看到了事件转发订阅管理器的配置

问题1:Get GPO-all结果中为什么没有显示事件转发策略

问题2:如何找到我需要的策略的GUID,以便我可以使用?除了提供密钥(我能够找到并确认它具有我通过gpedit.msc UI完成的配置)之外

问题3:如何计算相关策略的显示名称?我尝试了以下方法:

PS C:\Windows\PolicyDefinitions> Get-GPRegistryValue -Name SubscriptionManager -Key HKEY_LOCAL_MACHINE\SOFTWARE\Policies
\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager
我尝试使用不同的名称属性,如:“EventForwarding”、“EventForward”、“SubscriptionManager”甚至“Configure target Subscription Manager”。 下面是我得到的:

***Get-GPRegistryValue : The command cannot be completed because a GPO that is named "SubscriptionManager" was not found
in the nfstest.stbtest.microsoft.com domain. Make sure that the GPO that is specified by the Name parameter exists in
the domain that is specified for the cmdlet. Then, run the command again.
Parameter name: Name
At line:1 char:1
+ Get-GPRegistryValue -Name SubscriptionManager -Key HKEY_LOCAL_MACHINE\SOFTWARE\P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Group...tryValueCommand:GetGPRegistryValueCommand) [Get-GPReg
   istryValue], ArgumentException
    + FullyQualifiedErrorId : GpoWithNameNotFound,Microsoft.GroupPolicy.Commands.GetGPRegistryValueCommand***
如果您对这三个相关问题有任何帮助,我们将不胜感激

编辑1

如下图所示,当我手动配置taregt subscription manager时,我在注册表中获得了注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Policys\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager。我现在的问题很简单,我如何使用cmdlet做到这一点?到目前为止,我尝试的所有方法都没有在注册表中为我创建该项电子竞技,不是广告


谢谢

很抱歉,我不知道你在做什么。下面是一个完整的示例:

PS C:\silogix> Import-Module grouppolicy
PS C:\silogix> New-GPO -Name "MyGPO" | New-GPLink -target "OU=SousMonou,OU=MonOu,DC=dom,DC=fr" `
                       -linkenabled yes


GpoId       : f31df409-ca35-47cd-b699-52426e2bd196
DisplayName : MyGPO
Enabled     : True
Enforced    : False
Target      : OU=SousMonou,OU=MonOu,DC=dom,DC=fr
Order       : 1



PS C:\silogix> get-gpo -all


DisplayName      : Default Domain Policy
DomainName       : dom.fr
Owner            : DOM\Admins du domaine
Id               : 31b2f340-016d-11d2-945f-00c04fb984f9
GpoStatus        : AllSettingsEnabled
Description      :
CreationTime     : 16/09/2010 21:07:03
ModificationTime : 09/09/2011 21:04:06
UserVersion      : AD Version: 0, SysVol Version: 0
ComputerVersion  : AD Version: 11, SysVol Version: 11
WmiFilter        :

DisplayName      : Default Domain Controllers Policy
DomainName       : dom.fr
Owner            : DOM\Admins du domaine
Id               : 6ac1786c-016f-11d2-945f-00c04fb984f9
GpoStatus        : AllSettingsEnabled
Description      :
CreationTime     : 16/09/2010 21:07:03
ModificationTime : 06/06/2012 17:58:00
UserVersion      : AD Version: 0, SysVol Version: 0
ComputerVersion  : AD Version: 4, SysVol Version: 4
WmiFilter        :

DisplayName      : MyGPO
DomainName       : dom.fr
Owner            : DOM\Admins du domaine
Id               : f31df409-ca35-47cd-b699-52426e2bd196
GpoStatus        : AllSettingsEnabled
Description      :
CreationTime     : 08/06/2012 07:04:16
ModificationTime : 08/06/2012 07:04:16
UserVersion      : AD Version: 0, SysVol Version: 0
ComputerVersion  : AD Version: 0, SysVol Version: 0

PS C:\silogix> Set-GPRegistryValue -Name "MyGPO" -Key HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager -value "Server=https://EVTCPT:5986/wsman/SubscriptionManager/WEC" -t
ype String

PS C:\silogix> Get-GPRegistryValue -name "MyGPO" -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager"


KeyPath     : SOFTWARE\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager
FullKeyPath : HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager
Hive        : LocalMachine
PolicyState : Set
Value       : Server=https://EVTCPT:5986/wsman/SubscriptionManager/WEC
Type        : String
ValueName   : 1
HasValue    : True
因此,您可以在
GPMC.MSC
中看到它。

我已经编辑了我的问题。希望现在更清楚。我想知道,即使我看到gpedit.msc Subscription Manager被禁用,当我设置这样一个策略时,这是否有效?谢谢你确定使用gpedit的计算机在该策略的覆盖范围内吗?你是否验证应用了该策略?是的,我确定我设置了EventForw手动报警,如果这是您的意思,它就是转发事件。我只需要知道如何仅使用cmdlet来执行。您的上述解决方案是否有效,它是否将事件转发到收集器计算机?它应该如何工作?我根本无法更改注册表值?如果它使用手动编写的GPO工作,则它使用编程编写n gpo。