New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Re-import the module #6
Comments
Investigating... thanks for reporting this issue. |
@giertz Thanks for reporting this - I've found a fix and am in the process of releasing a new version. Just out of curiosity, why are you trying to unload/reload the module? Is there a specific scenario you need this functionality for? |
@rohitramu Im working on a console tool where you can load various cloud modules and then authenticate with stored credentials. There is a function builtin that allows the user to disconnect a current session, in this case it will just unload the module. So in a scenario where the user either wants to just "disconnect" or authenticate with a new account this function will be executed. |
Cool, that sounds interesting! Just in case you weren't aware: even when you unload a module, the currently loaded dll's will not be unloaded from memory - the cmdlets just won't be available to use. The easiest way I know of to unload dll's is to use separate PowerShell sessions. This way, you can just exit the sessions and the dll's will be unloaded from memory. An alternative is to just not unload the module at all. The "connection" is actually a bit of an illusion. Authentication for Microsoft Graph actually works by retrieving an authentication "token" when you run In terms of logging into a different account, you can do that with the following command, which will force a login window to open: Connect-MSGraph -ForceInteractive I have updated the release with the fix. Please download it again from the "Releases" tab in this repository. |
Thanks! You don't happen to know how long the token is valid during inactivity? |
I think it might be an hour. However, you shouldn't need to worry about that because the module will automatically refresh the token (i.e. get a new token) for you if it has expired. |
Hey,
If i try to import the module, then remove it from memory, then import it again i get "An item with the same key has already been added"
Removing the module:
Importing the module again
Any ideas why and how to solve it?
The text was updated successfully, but these errors were encountered: