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

Powershell将注册表转换为XML以进行GPO分配,xml,windows,powershell,registry,gpo,Xml,Windows,Powershell,Registry,Gpo,要通过域上的GPO定制任务栏固定应用程序,我必须具有注册表导出的XML版本。(没有windows 10任务栏固定应用设置,因此必须通过reg设置完成) 我已经寻找了注册表到XML转换器,这样我就可以为我的GPO创建一个XML文件,但我还没有找到一个运行正常的文件 是否有人链接到运行中的PowerShell脚本,或者可以确定这些脚本的错误 此页面中的脚本: 获取此错误: New-Object : Exception calling ".ctor" with "1" argument(s): "

要通过域上的GPO定制任务栏固定应用程序,我必须具有注册表导出的XML版本。(没有windows 10任务栏固定应用设置,因此必须通过reg设置完成)

我已经寻找了注册表到XML转换器,这样我就可以为我的GPO创建一个XML文件,但我还没有找到一个运行正常的文件

是否有人链接到运行中的PowerShell脚本,或者可以确定这些脚本的错误

此页面中的脚本:

获取此错误:

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
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
此处的脚本:

导致此错误的原因:

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
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

如果使用MS Gallery中的脚本(Convert-RegToGppXml.ps1),则应使用完整的源路径(例如C:\users\xyz\script.reg)。不要在路径中使用引号