How do I disconnect from Connect-MsolService in PowerShell
29,479
Solution 1
Just close the window.
As for your connection to Office 365, although there’s a Connect-MsolService cmdlet, there’s no corresponding Disconnect-MsolService cmdlet. So for Office 365, just close the Windows PowerShell window. (Nevertheless, it’s still a good idea to do this last so you can properly disconnect from SharePoint Online, Skype for Business Online, Exchange Online, and the Security & Compliance Center.)
https://technet.microsoft.com/en-us/library/dn568015.aspx
Solution 2
You can try to use the following .NET method: [Microsoft.Online.Administration.Automation.ConnectMsolService]::ClearUserSessionState()
Related videos on Youtube
Author by