简体   繁体   English

GPO未被应用

[英]GPO not being applied

I am using the powershell GroupPolicy module to create and link new GPOs. 我正在使用powershell GroupPolicy模块来创建和链接新的GPO。 I have a large number of GPOs to create, and thus I wish to automate the process without having to interact with the Group Policy Editor. 我有大量的GPO要创建,因此我希望自动化该过程而无需与组策略编辑器交互。

I noticed while creating GPOs through the editor that each policy object would be contained in either one or several XML files or .INI files. 我注意到在编辑器中创建GPO时,每个策略对象都包含在一个或多个XML文件或.INI文件中。

Having noted above, I started creating GPOs with the New-GPO command, passing the -Name and -Domain flags. 如上所述,我开始使用New-GPO命令创建GPO,并传递-Name和-Domain标志。 After the GPO has been successfully created, I would (via my script) generate an XML file containing all of the information that the policy would consume. 成功创建GPO后,我(通过我的脚本)生成一个XML文件,其中包含策略将使用的所有信息。 Shown below is an extract of the XML file that I would create to set up a mapped drives policy. 下面显示的是我将创建的XML文件的摘录,用于设置映射驱动器策略。

When inspecting the policy in the editor, everything looks fine. 在编辑器中检查策略时,一切看起来都很好。 The correct drives are showing up and all of the settings appear to be correct. 显示正确的驱动器,并且所有设置都显示正确。 However, the policy is never applied. 但是,该政策从未适用。 If I create an identical policy manually via the Group Policy Editor, all of the policies start working, including the ones that I created with powershell. 如果我通过组策略编辑器手动创建相同的策略,则所有策略都将开始工作,包括我使用PowerShell创建的策略。

The error therefore seems to be that the domain controller is never made aware of the changes, but they get applied when a manual change is made. 因此,错误似乎是域控制器永远不会知道更改,但是在进行手动更改时会应用它们。

I have tried running gpupdate /force, which does not seem to update or propagate the changes 我试过运行gpupdate / force,它似乎没有更新或传播更改

    New-Item \\$($MappedDrivesGPO.DomainName)\SYSVOL\$($MappedDrivesGPO.DomainName)\Policies\$("{"+$MappedDrivesGPO.Id+"}")\User\Preferences\Drives\Drives.xml -ItemType File -Force
    Set-Content \\$($MappedDrivesGPO.DomainName)\SYSVOL\$($MappedDrivesGPO.DomainName)\Policies\$("{"+$MappedDrivesGPO.Id+"}")\User\Preferences\Drives\Drives.xml $xml

<?xml version="1.0" encoding="utf-8"?>
    <Drives clsid="{8FDDCC1A-0C3C-43cd-A6B4-71A6DF20DA8C}">
        <Drive clsid="{935D1B74-9CB8-4e3c-9914-7DD559B7A417}" name="P:" status="P:" image="2" changed="2019-04-26 10:41:54" uid="{$guid1}" bypassErrors="1">
            <Properties action="U" thisDrive="NOCHANGE" allDrives="NOCHANGE" userName="" path="\\fs1\Projects" label="Projects" persistent="0" useLetter="1" letter="P"/>
            <Filters>
                <FilterGroup bool="AND" not="0" name="$($domainName)\Drive P Access" sid="$($filterGroupSidDriveP)" userContext="1" primaryGroup="0" localGroup="0"/>
            </Filters>
        </Drive>
        <Drive clsid="{935D1B74-9CB8-4e3c-9914-7DD559B7A417}" name="S:" status="S:" image="2" changed="2019-04-26 10:39:21" uid="{$guid2}" bypassErrors="1">
            <Properties action="U" thisDrive="NOCHANGE" allDrives="NOCHANGE" userName="" path="\\as1\Software" label="Software" persistent="0" useLetter="1" letter="S"/>
            <Filters>
                <FilterGroup bool="AND" not="0" name="$($domainName)\Drive S Access" sid="$($filterGroupSidDriveS)" userContext="1" primaryGroup="0" localGroup="0"/>
            </Filters>
        </Drive>
    </Drives>

I expected the policy to start working as intended after the XML file had been created 我希望策略在创建XML文件后按预期开始工作

The actual result is that the policy appears to be well formed, but never applied 实际结果是该政策似乎形成良好,但从未应用过

I managed to resolve this on my own, posting here in case someone else runs into the same issue. 我设法自己解决这个问题,发布在这里以防其他人遇到同样的问题。 If you're creating GPOs programmatically and not via the editor, you will have to extend your script/program to add CSE (in this case for drive mapping) and SnapIn GUID to gPCUserExtensionNames. 如果您是以编程方式而不是通过编辑器创建GPO,则必须扩展脚本/程序以将CSE(在本例中为驱动器映射)和SnapIn GUID添加到gPCUserExtensionNames。

[{00000000-0000-0000-0000-000000000000}{2EA1A81B-48E5-45E9-8BB7-A6E3AC170006}][{5794DAFD-BE60-433F-88A2-1A31939AC01F}{2EA1A81B-48E5-45E9-8BB7-A6E3AC170006}]

The 0000.. is the Core GPO Engine, 23EA.. is the Preference Tool CSE GUID Drives, 5794.. is Preference CSE GUID Drives. 0000 ..是核心GPO引擎,23EA ..是首选项工具CSE GUID驱动器,5794 ..是首选项CSE GUID驱动器。

If you create the policy manually with the desired changes, you can then open dsa.msc, enable advanced features and then view the policy object properties. 如果使用所需更改手动创建策略,则可以打开dsa.msc,启用高级功能,然后查看策略对象属性。 Under gPCUserExtensionNames you will be able to see the arrays containing the GUIDs that you need to incorporate in your software. 在gPCUserExtensionNames下,您将能够看到包含您需要在软件中包含的GUID的数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM