在Windows Small Business Server 2011 Essentials服务器上,提升的PowerShell命令Import-Module AdmPwd.PS失败并输出以下内容:
Import-Module : Could not load file or assembly 'file:///C:\Windows\system32\WindowsPowerShell\v1.0\Modules\AdmPwd.PS\AdmPwd.PS.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. At line:1 char:14 + Import-Module <<<< AdmPwd.PS + CategoryInfo : NotSpecified: (:) [Import-Module], BadImageFormatException + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand
PowerShell命令Get-ExecutionPolicy输出RemoteSigned ,据我所知,这是足够的,但PowerShell命令Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force无法解决问题。
https://social.technet.microsoft.com/Forums/Windows/en-US/fa0b7074-571d-4d84-b3b1-b214443b81b0/laps-importmodule-admpwdps-fail?forum=winserverpowershell和https://flamingkeys.com/部署-the-local-administrator-password-solution-part-2 /build议升级Windows Management Framework / PowerShell的安装将解决问题。
PowerShell命令$PSVersionTable.PSVersion输出如下内容:
Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1
https://www.microsoft.com/en-us/download/details.aspx?id=46899说:
支持的操作系统
Windows 10,Windows 7,Windows 8,Windows 8.1,Windows Server 2003,Windows Server 2008,Windows Server 2008 R2,Windows Server 2012,Windows Server 2012 R2,Windows Server 2016,Windows Vista活动目录:(需要AD架构扩展)
?Windows 2003 SP1或更高版本。
托pipe机器:
?Windows Server 2003 SP2或更高版本,或者Windows Server 2003 x64 Edition SP2或更高版本。
注意:不支持基于Itanium的计算机。
pipe理工具:
?.NET Framework 4.0
• PowerShell 2.0或更高版本
https://community.spiceworks.com/topic/1970987-sbs-2011-and-powershell-v3和https://blogs.technet.microsoft.com/sbs/2012/12/15/windows-management-framework- 3-0-app-on-windows-small-business-server-20082011-standard /强烈build议Windows SBS 2011和PowerShell 3存在兼容性问题。
https://tridion.stackexchange.com/questions/4497/import-module-could-not-load-file-or-assembly-when-running-2013-sp1-db-upgra和https:://code.msdn。 microsoft.com/windowsdesktop/Solution-for-management-of-ae44e789/view/Discussions/12提出,这个问题(1)是由于为.NET Framework 4版本编译的PowerShell模块引起的,但默认情况下,PowerShell只加载.NET Framework版本2和(2)可以通过创build文件C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config解决:
<?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0.30319"/> <supportedRuntime version="v2.0.50727"/> <supportedRuntime version="v4.6" /> </startup> </configuration>
我证实,这解决了这个问题。