cannot connect to exchange online via powershell

Anonymous
2020-06-24T16:23:06+00:00

I am unable to access exchange online via powershell anymore. it has been about 2 or 3 months since i have tried but this used to work with no issues. 

I have tried connecting 3 ways, all of which fail with the same error

#1

$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession -Session $Session -DisableNameChecking

the progress bar comes up, it says importing and counts up to 6 or 700 commands as expected then the unexpected error message:

Import-PSSession : Data returned by the remote Get-FormatData command is not in the expected format.

After that, none of the commands work - example Get-Mailbox 

#2

Connect-EXOPSSession -UserPrincipalName ******@x.com

same deal. same error

Import-PSSession : Data returned by the remote Get-FormatData command is not in the expected format.

At C:\Users\x\AppData\Local\Apps\2.0\A53V0WOT.PE1\6Y7OL9NA.H46\micr..tion_1f16bd4ec4c2bb19_0010.0000_673f37

c317fb5976\CreateExoPSSession.ps1:311 char:40

  • ...      $PSSessionModuleInfo = Import-PSSession $PSSession -AllowClobber

+                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidResult: (:) [Import-PSSession], ArgumentException

    + FullyQualifiedErrorId : ErrorMalformedDataFromRemoteCommand,Microsoft.PowerShell.Commands.ImportPSSessionCommand

#3

Connect-ExchangeOnline -UserPrincipalName ******@x.com -ShowProgress $true

same deal. same error

The module allows access to all existing remote PowerShell (V1) cmdlets in addition to the 9 new, faster, and more reliable cmdlets.

|--------------------------------------------------------------------------|

|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |

|--------------------------------------------------------------------------|

|    Get-CASMailbox                 |    Get-EXOCASMailbox                 |

|    Get-Mailbox                    |    Get-EXOMailbox                    |

|    Get-MailboxFolderPermission    |    Get-EXOMailboxFolderPermission    |

|    Get-MailboxFolderStatistics    |    Get-EXOMailboxFolderStatistics    |

|    Get-MailboxPermission          |    Get-EXOMailboxPermission          |

|    Get-MailboxStatistics          |    Get-EXOMailboxStatistics          |

|    Get-MobileDeviceStatistics     |    Get-EXOMobileDeviceStatistics     |

|    Get-Recipient                  |    Get-EXORecipient                  |

|    Get-RecipientPermission        |    Get-EXORecipientPermission        |

|--------------------------------------------------------------------------|

To get additional information, run: Get-Help Connect-ExchangeOnline or check https://aka.ms/exops-docs

Send your product improvement suggestions and feedback to ******@service.microsoft.com. For issues related to the module, contact Microsoft support. Don't use the feedback alias for problems or support issues.


Import-PSSession : Data returned by the remote Get-FormatData command is not in the expected format.

At C:\Program Files\WindowsPowerShell\Modules\ExchangeOnlineManagement\1.0.1\ExchangeOnlineManagement.psm1:454 char:40

  • ... oduleInfo = Import-PSSession $PSSession -AllowClobber -DisableNameChe ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidResult: (:) [Import-PSSession], ArgumentException

    + FullyQualifiedErrorId : ErrorMalformedDataFromRemoteCommand,Microsoft.PowerShell.Commands.ImportPSSessionCommand

At this point effectively unable to admin exchange online via powershell. Anyone have any ideas?

Microsoft 365 and Office | Subscription, account, billing | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

87 answers

Sort by: Most helpful
  1. Anonymous
    2020-06-25T22:09:49+00:00

    Same issue as everyone above. Everything still worked fine on Tuesday (6/24) and was broken on Wednesday (6/25).

    Is there an update to this? Not having access to Exchange Online with PowerShell is a bit of a problem for an O365 Exchange admin ...

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2020-06-25T18:15:17+00:00

    In my case i am the global administrator with MFA setup on the account. I dont think that anything has changed with my AD profile since i would be the one that would have to make that change.

    Second note - when i login via EOL V2, i am able to call the new methods such as "Get-EXOMailbox" without error but the format problem, prevents me from accessing the other 700 older methods that are being imported by the "Import-PSSession" cmdlet so this does not seem like an auth problem to me since I am able to call the EXO new methods in V2

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2020-06-25T18:02:28+00:00

    Using the following command:

    get-pssession | close-pssession

    Session = New-PSSession -Name O365 -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $RunAs -Authentication Basic -AllowRedirection }

    Import-PSSession $Session -AllowClobber -DisableNameChecking | Out-Null

    if fails at the "Import-PSSession" line.

    Data returned by the remote Get-FormatData command is not in the expected format.

    • CategoryInfo : InvalidResult: (:) [Import-PSSession], ArgumentException
    • FullyQualifiedErrorId : ErrorMalformedDataFromRemoteCommand,Microsoft.PowerShell.Commands.ImportPSSessionCommand
    • PSComputerName : localhost

    I ran like 10 times and it only got through once out of 10.

    Tryied it with different credentials ($runAs) with the exact same access rights and it goes through without any problem!

    Can it be related with the AD account ?

    Was this answer helpful?

    0 comments No comments
  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  5. Anonymous
    2020-06-25T17:39:45+00:00

    Same issue as well using the new module. It was working yesterday without issue.

    Was this answer helpful?

    0 comments No comments