Windows Terminal on Windows 11 with PowerShell sessions

Implemented

Windows Terminal on Windows 11 with PowerShell sessions

avatar

It appears as though RDM does not like Windows Terminal being set as the default terminal application on Windows 11 with embedded PowerShell sessions.

Upon launching a PowerShell session from within RDM, normally it will open up a PowerShell console within a tab in RDM.

Since I upgraded to Windows 11, however, I set my default terminal application to Windows Terminal. This is something that can be set either from within the Windows Terminal settings or Windows Settings under Privacy & Security > For developers.

Now when I open a PowerShell session from within RDM, it pops up with a Windows Terminal window instead of being an embedded tab. I wouldn't mind this, but most of our PowerShell sessions are set to run the following command upon launch:

cd Z:\; Try {Import-Module ExchangeOnlineManagement -ErrorAction Stop} Catch {Install-Module ExchangeOnlineManagement -Scope CurrentUser -Force; Import-Module ExchangeOnlineManagement}; Connect-ExchangeOnline -DelegatedOrganization "$DOMAIN_CUSTOM_FIELD1$"


The issue here is that the Exchange Online management module first pops up with an authentication window, then it cancels itself immediately and the Exchange module returns the following error:

Error Acquiring Token:
User canceled authentication.
New-ExoPSSession : One or more errors occurred.
At C:\Users\<removed>\Documents\WindowsPowerShell\Modules\ExchangeOnlineManagement\2.0.5\netFramework\ExchangeOnlineManagement.psm1:475
char:30
+ ... PSSession = New-ExoPSSession -ExchangeEnvironmentName $ExchangeEnviro ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-ExoPSSession], AggregateException
    + FullyQualifiedErrorId : System.AggregateException,Microsoft.Exchange.Management.ExoPowershellSnapin.NewExoPSSess
   ion


I also tried with another PowerShell session in RDM that has a similar thing where it launches the Azure AD PowerShell module. A similar behaviour occurs, but instead of the Azure AD authentication window getting cancelled, it freezes instead.

Changing the default terminal to Windows Console Host resolves this problem and the embedded PowerShell session works as normal.

Any ideas on how to resolve this issue or apply a workaround whilst keeping Windows Terminal as the default terminal?

All Comments (5)

avatar

Hello,

Thank you for reporting the issue. I was able to replicate the issue that the Windows Terminal is displaying externally. I will open an engineering ticket so they can have a look at the issue.

The workaround, unfortunately, is to use the Windows console host as the default terminal instead of the Windows Terminal.

Best regards,

Richard Boisvert

avatar

All good, thanks Richard

avatar

Hello,

We've implemented a fix, coming in 2022.3.11.0, that will make it possible to embed Powershell when Windows Terminal is the default. It will simply force Windows Console Host, because there is currently no way for us to properly embed Windows Terminal. Microsoft are aware of the situation, and they are looking at ways to work around the problem.

In the meantime, I hope this will be enough to solve your issues.

Regards

Jonathan Del Signore

avatar

Looking forward to the update. Thanks for the solution!

avatar

The fix works pretty well, thanks for looking into it.

The only thing I have noticed is that the problem remains if the default terminal is set to "Let Windows decide" (see screenshot below). Setting the default terminal to Windows Terminal implements the fix and works well.

forum image