'Connect-MsolService' is not recognized as the name of a cmdlet

后端 未结 4 1181
鱼传尺愫
鱼传尺愫 2021-02-09 01:13
        PSCommand commandToRun = new PSCommand();
        commandToRun.AddCommand(\"Connect-MsolService\");
        commandToRun.AddParameter(\"Credential\", new PSCrede         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 01:53

    This issue can occur if the Azure Active Directory Module for Windows PowerShell isn't loaded correctly.

    To resolve this issue, follow these steps.
    1.Install the Azure Active Directory Module for Windows PowerShell on the computer (if it isn't already installed). To install the Azure Active Directory Module for Windows PowerShell, go to the following Microsoft website:
    Manage Azure AD using Windows PowerShell

    2.If the MSOnline module isn't present, use Windows PowerShell to import the MSOnline module.

    Import-Module MSOnline 
    

    After it complete, we can use this command to check it.

    PS C:\Users> Get-Module -ListAvailable -Name MSOnline*
    
    
        Directory: C:\windows\system32\WindowsPowerShell\v1.0\Modules
    
    
    ModuleType Version    Name                                ExportedCommands
    ---------- -------    ----                                ----------------
    Manifest   1.1.166.0  MSOnline                            {Get-MsolDevice, Remove-MsolDevice, Enable-MsolDevice, Disable-MsolDevice...}
    Manifest   1.1.166.0  MSOnlineExtended                    {Get-MsolDevice, Remove-MsolDevice, Enable-MsolDevice, Disable-MsolDevice...}
    

    More information about this issue, please refer to it.


    Update:

    We should import azure AD powershell to VS 2015, we can add tool and select Azure AD powershell.

提交回复
热议问题