Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

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.

like image 650
Aathira Avatar asked Apr 06 '17 10:04

Aathira


1 Answers

I had to do this in that order:

Install-Module MSOnline
Install-Module AzureAD
Import-Module AzureAD
like image 128
Anthony O. Avatar answered Oct 06 '22 00:10

Anthony O.