'Connect-MsolService'不被识别为cmdlet的名称 [英] 'Connect-MsolService' is not recognized as the name of a cmdlet

查看:810
本文介绍了'Connect-MsolService'不被识别为cmdlet的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

        PSCommand commandToRun = new PSCommand();
        commandToRun.AddCommand("Connect-MsolService");
        commandToRun.AddParameter("Credential", new PSCredential(msolUsername, msolPassword));

        powershell.Streams.ClearStreams();
        powershell.Commands = commandToRun;
        powershell.Invoke();

我试图在Visual Studio中运行以上代码,并收到以下错误: 术语"Connect-MsolService"不能识别为cmdlet,函数,脚本文件或可运行程序的名称.检查名称的拼写,或者是否包含路径,请验证路径是否正确,然后重试. 但是我能够从Windows PowerShell的Microsoft Azure Active Directory模块连接到Msol服务.请帮忙.

I am trying to run above code in visual studio and getting the following error : The term 'Connect-MsolService' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. But I am able to Connect to Msol service from Microsoft Azure Active Directory Module for Windows PowerShell. Please help.

推荐答案

以下为我工作的东西:

  1. 卸载先前安装的"Microsoft Online Service登录助手"和用于Windows PowerShell的Windows Azure Active Directory模块".
  2. 安装64位版本的"Microsoft Online Service登录助手"和用于Windows PowerShell的Windows Azure Active Directory模块". https://littletalk .wordpress.com/2013/09/23/install-and-configure-the-office-365-powershell-cmdlets/
  1. Uninstall the previously installed ‘Microsoft Online Service Sign-in Assistant’ and ‘Windows Azure Active Directory Module for Windows PowerShell’.
  2. Install 64-bit versions of ‘Microsoft Online Service Sign-in Assistant’ and ‘Windows Azure Active Directory Module for Windows PowerShell’. https://littletalk.wordpress.com/2013/09/23/install-and-configure-the-office-365-powershell-cmdlets/

如果出现以下错误为了安装Windows PowerShell的Windows Azure Active Directory模块,必须在此计算机上安装Microsoft Online Services登录助手7.0或更高版本,然后安装适用于IT专业人员的Microsoft Online Services登录助手: http://www.microsoft.com/en-us/download/details.aspx?id = 39267

If you get the following error In order to install Windows Azure Active Directory Module for Windows PowerShell, you must have Microsoft Online Services Sign-In Assistant version 7.0 or greater installed on this computer, then install the Microsoft Online Services Sign-In Assistant for IT Professionals BETA: http://www.microsoft.com/en-us/download/details.aspx?id=39267

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

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

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

到文件夹

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

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

https://stackoverflow.com/a/16018733/5810078 .

(但是我实际上已经从

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

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

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

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

(要复制,您需要更改该文件夹的安全权限)

(For copying you need to alter the security permissions of that folder))

这篇关于'Connect-MsolService'不被识别为cmdlet的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆