6

I have used below command to initiates a connection to Azure Active Directory in Power Shell.

   Connect-​Msol​Service

I have completed required operations, But how do I disconnect? Do I wait till session expiry?!

enter image description here

kudlatiger
  • 351
  • 2
  • 5
  • 18

3 Answers3

7

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

Daniel
  • 6,780
  • 5
  • 31
  • 60
3

You can try to use the following .NET method: [Microsoft.Online.Administration.Automation.ConnectMsolService]::ClearUserSessionState()

1

I do have the same question. I found solution by reffering below article, We can use the .Net ClearUserSessionState method. It worked perfectly.

cmd : [Microsoft.Online.Administration.Automation.ConnectMsolService]::ClearUserSessionState()

Ref : https://www.easy365manager.com/how-to-disconnect-from-msolservice/

BALA S
  • 21
  • 3
  • While this may answer the question, it would be preferable to include the solution into the answer. Otherwise the answer gets useless when that link dies. – Gerald Schneider May 10 '22 at 09:23