Page 1 of 1

Importing Exchange Online Module

Posted: Tue Sep 21, 2021 8:12 am
by typody
To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: 2021 (5.8.194)
Operating system: Windows 11
PowerShell version(s): 6/7

*** Please add details and screenshots as needed below. ***



In previous editors I used to often write small scripts that are specific for a single purpose, changing an attribute on a list of mailboxes etc. Nothing serious just small things to help with admin. I would usually have the script in the main window and using the console window connect to the service required (Exchange, AD etc) and then run the script.

I import the Exchange Online module in the console window using:
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse ).FullName | Select-Object -Last 1) -Prefix EXO
which works fine and the new commands are available in the console. I then run connect-exopssession and nothing happens. It just sits there, no connection dialog asking for username/password/mfa etc. I have tried this using ISE, PowerGui and it works fine. Just wondering if I am missing something here.

Thanks in advance.

Re: Importing Exchange Online Module

Posted: Tue Sep 21, 2021 9:19 am
by brittneyr
First, I think its important that I point out that PowerShell Studio's embedded consoles do not function the same as in the ISE (I can't speak for PowerGui as I've never used it). Rather than being connected, the console and the editor run under different runspaces. For the editor specifically, it runs under a new runspace on every run. This was done intentionally to prevent runspace corruption. Nothing that is imported in a embedded console from the Console panel will affect a script when running (Ctrl+F5) or debugging (F5) unless you are always running the script in the console (Ctrl+F8).

Can you please provide a screenshot of what you are seeing? It is possible that the dialog is being suppressed in the Console panel. I don't have issues with console prompting for input, but I also do not have have Exchange Online nor can I specific support for it.

Re: Importing Exchange Online Module

Posted: Tue Sep 21, 2021 10:02 am
by typody
Capture.PNG (24.02 KiB) Viewed 5846 times
Sure here you go. It's not a very useful screenshot!

Re: Importing Exchange Online Module

Posted: Tue Sep 21, 2021 10:42 am
by brittneyr
From your screenshot, I can see you are using the PowerShell 5.1 console. From my quick research, others have found issues with PowerShell 5.1 and the Microsoft Exchange Online module 2.0.4 or later. In your original post, you specified PowerShell 7 as installed. Does this work with the PowerShell 7 console? ... ngs/4673/4

Re: Importing Exchange Online Module

Posted: Tue Sep 21, 2021 10:49 am
by typody
That's sorted it, thanks. However from your first post what I am attempting to do won't work anyway, if I read it correctly. I see why it was done that way, I was hoping to get rid of my other PS consoles but for certain quick and dirty scripts I think I will need them based on what you said.