![powershell sccm 导入模块错误](https://linux22.com/image/657397/powershell%20sccm%20%E5%AF%BC%E5%85%A5%E6%A8%A1%E5%9D%97%E9%94%99%E8%AF%AF.png)
已从以下位置下载 sccm powershell 模块https://www.microsoft.com/en-us/download/details.aspx?id=46681
通过 .msi 安装没有问题。导入时,如下所示:
> Import-Module 'C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' -Verbose
>
> Output (first few lines, many more snipped for brevity, then the
> error):
>
> VERBOSE: Loading module from path 'C:\Program Files (x86)\Microsoft
> Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1'.
> VERBOSE: Loading 'Assembly' from path 'C:\Program Files
> (x86)\Microsoft Configuration
> Manager\AdminConsole\bin\AdminUI.PS.TypeAdapter.dll'. VERBOSE: Loading
> 'Assembly' from path 'C:\Program Files (x86)\Microsoft Configuration
> Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.ManagementProvider.dll'.
> VERBOSE: Loading 'Assembly' from path 'C:\Program Files
> (x86)\Microsoft Configuration
> Manager\AdminConsole\bin\AdminUI.WqlQueryEngine.dll'. VERBOSE: Loading
> 'TypesToProcess' from path 'C:\Program Files (x86)\Microsoft
> Configuration
> Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml'.
...
> VERBOSE: Importing cmdlet 'Clear-CMMigrationData'. VERBOSE: Loading
> module from path 'C:\Program Files (x86)\Microsoft Configuration
> Manager\AdminConsole\bin\AdminUI.PS.DatabaseReplication.dll'.
> Import-Module : Could not load type
> 'Microsoft.ConfigurationManagement.AdminConsole.Common.InvAvailabilityLevel'
> from assembly 'AdminUI.Common, Version=5.0.0.0, Culture=neutral,
> PublicKeyToken=31bf3856ad364e35'. At line:1 char:1
> + Import-Module $CMModulePath -Verbose
> + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + CategoryInfo : NotSpecified: (:) [Import-Module], TypeLoadException
> + FullyQualifiedErrorId : System.TypeLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
与错误相关的 DLL 相当新:
PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin> dir AdminUI.PS.DatabaseReplication*
Directory: C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/6/2015 4:00 AM 40112 AdminUI.PS.DatabaseReplication.dll
看起来安装失败了,因为我没有看到任何命令:
PS C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin> Get-Command -Module ConfigurationManager | measure-object
计数 : 0 平均值 : 总和 : 最大值 : 最小值 : 属性 :
不确定接下来该怎么做
答案1
问题似乎是我们运行的 SCCM 是“System Center 2012”,而不是“System Center 2012 R2”
经过大量搜索后,我看到了“System Center Configuration Manager Cmdlet Library”:
此版本支持以下版本的 Configuration Manager:
System Center 2012 R2 Configuration Manager
而原始下载网站则说:
支持的操作系统
Windows 7、Windows 8、Windows 8.1、Windows Server 2008、Windows Server 2008 R2、Windows Server 2012、Windows Server 2012 R2
当然,我很高兴尝试在 Windows 7 上完成此操作。
唉。看来我们需要将 SCCM 更新到 R2 才能让 pwoershell 与其一起工作。
[编辑] 发现 SP1 也有 cmdlet,所以我必须让控制我们的 SCCM 服务器的人至少升级到那个...