安装了Azure Active Directory模块,它工作得很好;但仅当我使用安装向导创建的快捷方式启动PowerShell时 . 无法弄清楚为什么当通过cmd.exe进行此操作时它会像冠军一样,但当我尝试直接从PowerShell会话导入模块时却无法解决 .

正常使用快捷方式或将其命令字符串粘贴到传统命令提示符中成功加载模块:

Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Windows\system32>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  -NoExit -Command "Import-Module MSOnline"
PS C:\Windows\system32> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.1.166.0  MSOnline                            {Add-MsolAdministrativeUnitMember, Add-MsolFo...

但是,以“管理员”身份打开PowerShell会话并尝试在同一系统上导入同一模块会抛出此错误:

PS C:\Windows\system32> Import-Module MSOnline
Import-Module : Could not load file or assembly 'file:///C:\Program Files
(x86)\WindowsPowerShell\Modules\MSOnline\1.1.166.0\Microsoft.Online.Administration.Automation.PSModule.dll' or one of its
dependencies. An attempt was made to load a program with an incorrect format.

为什么我必须通过旧的命令提示符走这个特定的模块才能使它运行,当我导入的每个其他模块没有任何问题?