Azure-docs: Connect-MsolService runs into

Created on 29 Jan 2020  Â·  5Comments  Â·  Source: MicrosoftDocs/azure-docs

Dear All,

on Azure Cloud Shell running Import-Module MSOnline generates =>"Import-Module : Assembly with same name is already loaded".
Then running Connect-MsolService runs into => "Connect-MsolService : The term 'Connect-MsolService' is not recognized as the name of a cmdlet, function, script file, or operable program."
Is there any other script to activate MFA?
Thanks,
Alex


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 active-directorsvc authenticatiosubsvc cxp product-question triaged

All 5 comments

@AlexanderTodorovic, Thank you for reaching out. We are looking into this and will update you shortly.

@AlexanderTodorovic, You can try the following script: https://gallery.technet.microsoft.com/scriptcenter/Enable-Azure-MFA-Powershell-f2591bca

Do let me know if this helped or not.

@souravmishra-msft Unfortunately the script runs into the same error.

@AlexanderTodorovic, The Connect-MSolservice cmdlet would not work with the cloudshell since thats a legacy module and it is not compatible with the cloudshell. Secondly if you are trying to run Connect-MSOLService cmdlet on a normal PowerShell, you would need to install the module first and make its cmdlets available. Looking at the error, it looks like the MSOnline module itself is missing from the Powershell which you are trying to use.

You can follow the steps to check and install the MSOnline module for your powershell.

  1. Installing MSOnline module:
Install-Module MsOnline
Import-Module MsOnline
  1. In case Step 1 fails, you can download the MSOnline module first and then import it.
    image

    # Save the MSOnline Module under the location C:\Temp\
    PS C:\> Save-Module MsOnline -Path C:\temp\
     
    #To import the module, run the following command:
    PS C:\> Import-Module -Name "C:\Temp\MsOnline" -Verbose
    
  2. To check if the installation has been successful or not (also to check if the MSOnline module is earlier present in your system or not.)

    (Get-Item C:\Windows\System32\WindowsPowerShell\v1.0\Modules\MSOnline\Microsoft.Online.Administration.Automation.PSModule.dll).VersionInfo.FileVersion

Do let me know following the steps above you were able to install the MSOnline module or not. If it fails, do let me know the error with which it fails. If the installation of the MSOnline module works fine, go ahead and try running that script once again. Then it should run as the Connect-MSolService would be available for the script to execute.

With Save-Module MsOnline and then Import-Module -Name all works fine and
Connect-MsolService can be successfully invoked. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulmarshall picture paulmarshall  Â·  3Comments

bityob picture bityob  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments

varma31 picture varma31  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments