在安装过程中“提供程序加载失败”('Provider load failure' d

2019-10-29 22:45发布

我在从在Windows 10物联网企业桌面应用程序的安装过程执行两个PowerShell脚本。

%WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File ".\KeyboardFilter.ps1"
%WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File ".\ShellLauncher.ps1"

但是PowerShell脚本的执行没有成功。 我收到以下错误:

Get-WMIObject : Provider load failure
At C:\Program Files\Application\KeyboardFilter.ps1:31 char:19
+ ... $predefined = Get-WMIObject -class WEKF_PredefinedKey @CommonParams |
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


Write-Error : A positional parameter cannot be found that accepts argument 'is'.
At C:\Program Files\Application\KeyboardFilter.ps1:41 char:9
+         Write-Error $Id is not a valid predefined key
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Write-Error], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WriteErrorCommand


enable-windowsoptionalfeature : An attempt was made to load a program with an incorrect format.
At C:\Program Files\Application\ShellLauncher.ps1:4 char:1
+ enable-windowsoptionalfeature -online -featureName Client-EmbeddedShe ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand

安装过程开始管理权限。 第一个脚本添加组合键的键盘过滤(视窗10物联网功能)。

第二个脚本启用和配置壳牌启动(也是Windows 10物联网功能)。

KeyboardFilter.ps1:

 param (
     [String] $ComputerName
 )

 $CommonParams = @{"namespace"="root\standardcimv2\embedded"}
 $CommonParams += $PSBoundParameters

 function Enable-Predefined-Key($Id) {   
     $predefined = Get-WMIObject -class WEKF_PredefinedKey @CommonParams |
         where {
             $_.Id -eq "$Id"
         };

     if ($predefined) {
         $predefined.Enabled = 1;
         $predefined.Put() | Out-Null;
         Write-Host Enabled $Id
     } else {
         Write-Error $Id is not a valid predefined key
     }
 }

如果我在一个批处理文件或PowerShell控制台上执行的PowerShell脚本,一切工作正常。 我也试过在使用PowerShell x86和x64,同样的错误在这两种情况下,安装过程中执行PowerShell脚本。

任何提示,提示或解决这个问题?

文章来源: 'Provider load failure' during installation process