简体   繁体   English

Powershell将注册表转换为XML以进行GPO分配

[英]Powershell to convert registry to XML for GPO assignment

To have the taskbar pinned applications customized via a GPO on a domain I have to have an XML version of a registry export. 要通过域上的GPO自定义任务栏固定的应用程序,我必须具有注册表导出的XML版本。 (There is not a windows 10 Taskbar Pinned apps setting so it has to be done via reg setting) (没有Windows 10任务栏固定的应用程序设置,因此必须通过reg设置完成)

I have looked for registry-to-XML converters so that I can have an XML file for my GPO, but I have not found a functioning one. 我一直在寻找从注册表到XML的转换器,以便可以为我的GPO使用XML文件,但是我没有找到能正常工作的文件。

Does anyone have a link to a functioning powersheel script, or can identify what is wrong with these? 是否有人链接到正在运行的powersheel脚本,或者可以确定这些脚本出了什么问题?

The script from this page: https://4sysops.com/archives/convert-reg-to-xml-to-import-registry-key-into-group-policy-preferences/ 此页面中的脚本: https : //4sysops.com/archives/convert-reg-to-xml-to-import-registry-key-into-group-policy-preferences/

https://4sysops.com/wp-content/uploads/2014/09/RegToXML.zip https://4sysops.com/wp-content/uploads/2014/09/RegToXML.zip

gets me this error: 让我这个错误:

New-Object : Exception calling ".ctor" with "1" argument(s): "Could not find file 'C:\WINDOWS\system32\test1.reg'."
At C:\RegToXML.ps1:43 char:7
+   $sr=New-Object System.IO.StreamReader($regPath)
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
You cannot call a method on a null-valued expression.
At C:\RegToXML.ps1:53 char:5
+     $line = $sr.ReadLine()
+     ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

The script from here: https://gallery.technet.microsoft.com/scriptcenter/Registry-To-GroupPolicyPref-9feae9a3 此处的脚本: https : //gallery.technet.microsoft.com/scriptcenter/Registry-To-GroupPolicyPref-9feae9a3

Results in this error: 导致此错误:

C:\Convert-RegToGppXml.ps1 : Cannot process argument transformation on parameter 'SourcePath'. Cannot convert the
".\test1.reg" value of type "System.String" to type "System.Management.Automation.ValidateNotNullOrEmptyAttribute".
At line:1 char:39
+ .\Convert-RegToGppXml.ps1 -SourcePath .\test1.reg -ResultPath .\test1 ...
+                                       ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Convert-RegToGppXml.ps1], ParameterBindingArgumentTransformationExcept
   ion
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Convert-RegToGppXml.ps1

If you use that script from MS-Gallery ( Convert-RegToGppXml.ps1 ) then you should use the complete Sourcepath (eg C:\\users\\xyz\\script.reg). 如果您使用MS-Gallery中的脚本(Convert-RegToGppXml.ps1),则应使用完整的Sourcepath(例如C:\\ users \\ xyz \\ script.reg)。 Dont use quotation marks in path! 请勿在路径中使用引号!

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

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