windows 无法在 PowerShell 上导入 MSOnline(Connect-MsolService 错误)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16018732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:26:14  来源:igfitidea点击:

MSOnline can't be imported on PowerShell (Connect-MsolService error)

windowspowershellazure64-bitcmdlets

提问by Danny Fallas

I had this issue and couldn′t find any answer. The issue was that I was trying to use Azure cdmlets to connect to O365 via c# code, but I couldn′t get the connect-msolservice.

我有这个问题,找不到任何答案。问题是我试图使用 Azure cdmlets 通过 c# 代码连接到 O365,但我无法获得connect-msolservice.

""The term is not recognized" error when you try to run administrative Windows PowerShell cmdlets in Office 365"

当您尝试在 Office 365 中运行管理 Windows PowerShell cmdlet 时出现“无法识别术语”错误

回答by mythofechelon

After reviewing Microsoft's TechNet article "Azure Active Directory Cmdlets" -> section "Install the Azure AD Module", it seems that this process has been drastically simplified, thankfully.

在查看了 Microsoft 的 TechNet 文章“Azure Active Directory Cmdlets”->“安装 Azure AD 模块”部分后,谢天谢地,这个过程似乎已经大大简化了。

As of 2016/06/30, in order to successfully execute the PowerShell commands Import-Module MSOnlineand Connect-MsolService, you will need to install the following applications (64-bit only):

截至 2016 年 6 月 30 日,为了成功执行 PowerShell 命令Import-Module MSOnlineConnect-MsolService,您需要安装以下应用程序(仅限 64 位):

  1. Applicable Operating Systems: Windows 7 to 10
    Name: "Microsoft Online Services Sign-in Assistant for IT Professionals RTW"
    Version: 7.250.4556.0(latest)
    Installer URL: https://www.microsoft.com/en-us/download/details.aspx?id=41950
    Installer file name: msoidcli_64.msi
  2. Applicable Operating Systems: Windows 7 to 10
    Name: "Windows Azure Active Directory Module for Windows PowerShell"
    Version: Unknown but the latest installer file's SHA-256 hash is D077CF49077EE133523C1D3AE9A4BF437D220B16D651005BBC12F7BDAD1BF313
    Installer URL: https://technet.microsoft.com/en-us/library/dn975125.aspx
    Installer file name: AdministrationConfig-en.msi
  3. Applicable Operating Systems: Windows 7 only
    Name: "Windows PowerShell 3.0"
    Version: 3.0(later versions will probably work too)
    Installer URL: https://www.microsoft.com/en-us/download/details.aspx?id=34595
    Installer file name: Windows6.1-KB2506143-x64.msu
  1. 适用操作系统:Windows 7 到 10
    名称:“Microsoft Online Services Sign-in Assistant for IT Professionals RTW”
    版本:(7.250.4556.0最新)
    安装程序 URL:https: //www.microsoft.com/en-us/download/details.aspx ?id=41950
    安装程序文件名:msoidcli_64.msi
  2. 适用操作系统:Windows 7 到 10
    名称:“Windows Azure Active Directory Module for Windows PowerShell”
    版本:未知,但最新安装程序文件的 SHA-256 哈希是D077CF49077EE133523C1D3AE9A4BF437D220B16D651005BBC12F7BDAD1BF313
    安装程序 URL:https: //technet.microsoft.com/en-us/ library/dn975125.aspx
    安装程序文件名:AdministrationConfig-en.msi
  3. 适用操作系统:仅限Windows 7
    名称:“Windows PowerShell 3.0”
    版本:(3.0更高版本可能也适用)
    安装程序 URL:https: //www.microsoft.com/en-us/download/details.aspx?id=34595
    安装程序文件名:Windows6.1-KB2506143-x64.msu

 

 

enter image description hereenter image description hereenter image description here

在此处输入图片说明在此处输入图片说明在此处输入图片说明

回答by Danny Fallas

After hours of searching and trying I found out that on a x64 server the MSOnline modules must be installed for x64, and some programs that need to run them are using the x86 PS version, so they will never find it.

经过数小时的搜索和尝试,我发现在 x64 服务器上必须为 x64 安装 MSOnline 模块,而一些需要运行它们的程序使用的是 x86 PS 版本,因此他们永远找不到它。

[SOLUTION]What I did to solve the issue was:

[解决方案]我为解决问题所做的是:

Copy the folders called MSOnlineand MSOnline Extendedfrom the source

从源中复制名为MSOnline和的文件夹MSOnline Extended

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\

to the folder

到文件夹

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\

And then in PS run the Import-Module MSOnline, and it will automatically get the module :D

然后在PS中运行Import-Module MSOnline,它会自动获取模块:D

回答by Victor Shostak

The solution with copying 32-bit libs over to 64-bit did not work for me. What worked was unchecking Target Platform Prefer 32-bit check mark in project properties.

将 32 位库复制到 64 位的解决方案对我不起作用。有效的是取消选中项目属性中的目标平台首选 32 位复选标记。

回答by DaleyKD

I'm using a newer version of the SPO Management Shell. For me to get the error to go away, I changed my Import-Module statement to use:

我使用的是较新版本的 SPO 命令行管理程序。为了让错误消失,我将 Import-Module 语句更改为使用:

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking;

Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking;

I also use the newer command:

我也使用较新的命令:

Connect-SPOService

Connect-SPOService

回答by ernitingoel

Connects to both Office 365 and Exchange Online in one easy to use script.

在一个易于使用的脚本中连接到 Office 365 和 Exchange Online。

REMINDER: You must have the following installed in order to manage Office 365 via PowerShell.

提醒:您必须安装以下软件才能通过 PowerShell 管理 Office 365。

Microsoft Online Services Sign-in Assistant: http://go.microsoft.com/fwlink/?LinkId=286152

Microsoft 在线服务登录助手:http: //go.microsoft.com/fwlink/?LinkId=286152

Azure AD Module for Windows PowerShell 32 bit - http://go.microsoft.com/fwlink/p/?linkid=23629864 bit - http://go.microsoft.com/fwlink/p/?linkid=236297

适用于 Windows PowerShell 32 位的 Azure AD 模块 - http://go.microsoft.com/fwlink/p/?linkid=23629864 位 - http://go.microsoft.com/fwlink/p/?linkid=236297

MORE INFORMATION FOUND HERE: http://technet.microsoft.com/en-us/library/hh974317.aspx

在这里找到更多信息:http: //technet.microsoft.com/en-us/library/hh974317.aspx

回答by Jose Ortega

The following is needed:

需要以下内容:

  • MS Online Services Assistant needs to be downloaded and installed.
  • MS Online Module for PowerShell needs to be downloaded and installed
  • Connect to Microsoft Online in PowerShell
  • 需要下载并安装 MS 在线服务助手。
  • 需要下载并安装适用于 PowerShell 的 MS 在线模块
  • 在 PowerShell 中连接到 Microsoft Online

Source: http://www.msdigest.net/2012/03/how-to-connect-to-office-365-with-powershell/

来源:http: //www.msdigest.net/2012/03/how-to-connect-to-office-365-with-powershell/

Then Follow this one if you're running a 64bits computer: I'm running a x64 OS currently (Win8 Pro).

如果您运行的是 64 位计算机,请按照以下步骤操作:我当前运行的是 x64 操作系统(Win8 Pro)。

Copy the folder MSOnline from (1) –> (2) as seen here

从 (1) –> (2) 复制文件夹 MSOnline,如下所示

1) C:\Windows\System32\WindowsPowerShell\v1.0\Modules(MSOnline)

1) C:\Windows\System32\WindowsPowerShell\v1.0\Modules(MSOnline)

2) C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules(MSOnline)

2) C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules(MSOnline)

Source: http://blog.clauskonrad.net/2013/06/powershell-and-c-cant-load-msonline.html

来源:http: //blog.clauskonrad.net/2013/06/powershell-and-c-cant-load-msonline.html

Hope this is better and can save some people's time

希望这更好,可以节省一些人的时间