If you are facing this issue, you are not alone. In my case, I had run the install-Msolservice command before and it completed with no errors but nothing seemed to be installed, therefore it didn’t connect or recognize the modules in the machine. Here are the steps to get it fixed.
Open PowerShell as Admin –> Run the following commands in sequence (ensure your machine is connected to internet)
Firstly, uninstall the Azure-AD module
The re-install it
Try to run this. It will complete without any errors if you have the module existed but somehow corrupted (It could fail too but just run it anyways to verify)
Now re-install the MSOnline Module
And now you can connect to O365. It should prompt you for credentials to login
Once completed, the following command can be used to verify the installation.
Get-Module -ListAvailable -Name MSOnline*