Powershell

powershell sccm 導入模組錯誤

  • May 1, 2015

已從https://www.microsoft.com/en-us/download/details.aspx?id=46681下載了 sccm powershell 模組

通過 .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 | 測量對象

計數:0 平均值:總和:最大值:最小值:屬性:

不知道如何從這裡開始

看起來問題是我們正在執行的 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 使用它。

$$ edit $$發現 SP1 也有 cmdlet,所以我必須讓控制我們 SCCM 伺服器的人至少升級到那個…

引用自:https://serverfault.com/questions/687000