EvotecIT / O365Essentials

A module that helps to manage some tasks on Office 365/Azure via undocumented API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disconnect-O365Admin missing

SVAjcuepper opened this issue · comments

Hello,

I hope someone can help me here. There is no CMDlet to disconnect from all session created with "Connect-O365Admin". Is there a workaround?

Thank you

This is because Connect-O365Admin uses Connect-AzAccount and within the same run it also does Disconnect-AzAccount as soon as it gets the token. So in theory there's nothing to disconnect from. There is a Session that stays open until you actually restart PowerShell. I guess one could add Disconnect-O365Admin which basically would do $Script:AuthorizationO365Cache = $null and it would clear the cache of all tokens so when you run Connect-O365Admin it would retrigger new connection (if that's what you are after?)

Yes exactly, thats what im after. I have to connect to multiple Tenants a lot of times and I do not want to restart the PowerShell everytime.

Can you send me a code-snippet or add the CMDlet ?

Thank you for your response!

I managed to add the function myself and I can confirm that is works. It would be nice if you can add it to the module and publish a new version in PSGallery.

Changes in PSM1-file
function Disconnect-O365Admin { $Script:AuthorizationO365Cache = $null }

# Export functions and aliases as required Export-ModuleMember -Function @('Connect-O365Admin','Disconnect-O365Admin', 'ConvertFrom-JSONWebToken', [...]

Changes in PSD1-file
FunctionsToExport = @('Connect-O365Admin','Disconnect-O365Admin', 'ConvertFrom-JSONWebToken', [...]

Good day @PrzemyslawKlys ,

are you going to add the function to the module? If you do not have time or ambition to add the function, please let me know.

Thank you in advance

I've already added it, just haven't had time to publish, check other things around module. Since you modified you own version I guess there's no hurry in doing any publishing.

Thank you for adding the function and planning of updating the version in PSGallery. I didn't mean to pressure you, I just wasn't sure if you were already working on the implementation.