Importing Exchange Online Module

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
typody
Posts: 7
Last visit: Wed Oct 27, 2021 7:09 am

Importing Exchange Online Module

Post 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. ***

DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Hi,

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.

User avatar
brittneyr
Site Admin
Posts: 921
Last visit: Thu Dec 02, 2021 11:28 am
Answers: 21
Been upvoted: 17 times

Re: Importing Exchange Online Module

Post 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.
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
typody
Posts: 7
Last visit: Wed Oct 27, 2021 7:09 am

Re: Importing Exchange Online Module

Post by typody »

Capture.PNG
Capture.PNG (24.02 KiB) Viewed 5855 times
Sure here you go. It's not a very useful screenshot!

User avatar
brittneyr
Site Admin
Posts: 921
Last visit: Thu Dec 02, 2021 11:28 am
Answers: 21
Been upvoted: 17 times

Re: Importing Exchange Online Module

Post 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?

https://forums.ironmansoftware.com/t/ex ... ngs/4673/4
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
typody
Posts: 7
Last visit: Wed Oct 27, 2021 7:09 am

Re: Importing Exchange Online Module

Post 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.