"PowerShell has stopped working" issue when working with Office 365 Remote Exchange PowerShell

2015-09-02 | Toni Pohl

We are using a lot of PowerShell for configuring Office 365 tenants and Exchange Online.

When getting new requests, I usually use my existing PS-Scripts to connect to Exchange Online, modify them, execute them and that’s it – that’s the real world scenario.

Recently I had the issue that – when connecting to Exchange Online – I always got the error "PowerShell has stopped working" or when using PS ISE "PowerShell_ise has stopped working".

image

First I suspected that there was an issue with my Windows 10 Updates on PowerShell…

These tips did not help:

Then I found out the (simple) reason. See my full connect.ps1 script here.

image

The parameter -ConnectionUri with the value https://ps.outlook.com/powershell/ and –AllowRedirection caused that issue. That’s the issue and the fix:

# WRONG:
# $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic –AllowRedirection

# CORRECT:
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection

I had in mind that the URI was renewed (some time ago), but simply had forgotten about this.
When using the correct -ConnectionUri value "https://outlook.office365.com/powershell-liveid/" everything works again.

I need to update my PS connection scripts… Zwinkerndes Smiley

Hope this tip helps!

Categories: Exchange, English, Microsoft, Office365, PowerShell

Source: https://blog.atwork.at/post/PowerShell-has-stopped-working-issue-when-working-with-Office-365-Remote-Exchange-PowerShell