To disconnect from MsolService in PowerShell, you can use the .Net ClearUserSessionState method.
[Microsoft.Online.Administration.Automation.ConnectMsolService]::ClearUserSessionState()
This command is used to clear the user session state for the current Office 365 user. It will cause the user to be logged out of Office 365. This command will clear all of the variables and objects that are stored in the user session state.
The [Microsoft.Online.Administration.Automation.ConnectMsolService]
type is a PowerShell class that represents the Connect-MsolService cmdlet. The ClearUserSessionState() method is a method of this class that can be used to disconnect the user MSolService.
Conclusion
I hope the above article on how to disconnect from MSolService in PowerShell is helpful to you.
[Microsoft.Online.Administration.Automation.ConnectMsolService]::ClearUserSessionState()
Once you run the above command, you will need to reconnect to Office 365 or Azure Active Directory using the Connect-MsolService cmdlet.
Connect-MsolService
This command will prompt you to enter your Office 365 username and password to initiate a connection to Office 365.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.