-->

如何打通的Windows PowerShell组策略cmdlet的/设置/更新注册表值?(How t

2019-09-17 21:41发布

我已经配置EventForwarding手动的,但我wondeing如果我能做到这一点编程,我穿过来了组策略cmdlet ,这似乎是解决方案。 下面是我想在下面的图片中手动配置。

当我运行Get-GPO cmdlet的-all我没有看到相关的事件转发任何的GPO。 然而,当我跑的Get-GPResultantSetOfPolicy与XML文件的指定路径,我看到我的事件转发的订阅管理器的配置。

问题1:为什么进不去的GPO没有显示事件转发政策-all结果呢?

问题2:如何找出我需要这样我就可以使用该策略的GUID 获取-GPRegistryValue ? 除提供密钥(这是我能找到,并请验证是否有我的配置,我已经通过输入gpedit.msc UI完成。

问题3:如何找出有问题的政策的显示名称? 我试过如下:

PS C:\Windows\PolicyDefinitions> Get-GPRegistryValue -Name SubscriptionManager -Key HKEY_LOCAL_MACHINE\SOFTWARE\Policies
\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager

当我试图为Name属性像不同的东西:“EventForwarding”,“EventForward”,“SubscriptionManager”,甚至“配置目标订阅管理”。 这里是我得到了什么:

***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订阅管理器,我拿到钥匙HKEY_LOCAL_MACHINE \ SOFTWARE \政策\微软\的Windows \事件日志\ EventForwarding \注册表SubscriptionManager。 我现在的问题很简单,我怎么能做到这一点与cmdlet的? 所有我试图到目前为止没有在注册表中创建该密钥对我来说,不是广告。

谢谢

Answer 1:

对不起不是一定要了解你做什么。 下面是一个完整的例子:

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



文章来源: How to get/set/update registry value through group policy cmdlet of Windows PowerShell?