can't install msonline in powershell

Anonymous
2022-05-17T13:49:11+00:00

I have been trying to install msonline, but i get the following error, please help how to fix. Working for many hours, but no solution found yet

Import-Module : Could not load file or assembly 'file:///C:\Program 

Files\WindowsPowerShell\Modules\msonline\1.1.183.66\Microsoft.Online.Administration.Automation.PSModule.dll' or one of its dependencies. An attempt was made to load a 

program with an incorrect format.

At line:1 char:1

+ Import-Module msonline

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

    + CategoryInfo          : InvalidOperation: (:) [Import-Module], BadImageFormatException

    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

Microsoft 365 and Office | SharePoint | For education | Android

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
Answer accepted by question author
Anonymous
2022-05-17T20:10:34+00:00

Hi Cliff,

The issue is resolved now, One another member of the community told me to run the import-module msonline not in PS (X86) run it in only PS or PS ISE, so it worked.

Thank you for you help. Appreciated

Have a great time

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-05-18T14:51:39+00:00

    Dear Abdul,

    Thanks for your reply and I'm glad to hear that the issue has been resolved by yourself in your environment.

    Welcome to post a new thread on our forum at your convenience if you encounter any issues.

    Have a nice day!

    Cliff

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2022-05-17T16:49:18+00:00

    Hi Cliff,

    Thank you for help.

    My OS is windows 10 pro

    The version is as follow:

    Name                           Value                                                                                                                                     

    ----                           -----                                                                                                                                     

    PSVersion                      5.1.19041.1645                                                                                                                            

    PSEdition                      Desktop                                                                                                                                   

    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                   

    BuildVersion                   10.0.19041.1645                                                                                                                           

    CLRVersion                     4.0.30319.42000                                                                                                                           

    WSManStackVersion              3.0                                                                                                                                       

    PSRemotingProtocolVersion      2.3                                                                                                                                       

    SerializationVersion           1.1.0.1 

    Microsoft .NET Framework 3.5.x was not enabled, I enabled it and restarted my computer and I am logged in as administrator to PS ISE, ran the commands again, got the following error.

    PS C:\WINDOWS\system32> Install-Module msonline

    PS C:\WINDOWS\system32> Import-Module msonline

    Import-Module : Could not load file or assembly 'file:///C:\Program 

    Files\WindowsPowerShell\Modules\msonline\1.1.183.66\Microsoft.Online.Administration.Automation.PSModule.dll' or one of its dependencies. An attempt was made to load a 

    program with an incorrect format.

    At line:1 char:1

    + Import-Module msonline

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

        + CategoryInfo          : InvalidOperation: (:) [Import-Module], BadImageFormatException

        + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

    The execution policy set to unrestricted

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-05-17T16:14:52+00:00

    Dear Abdul,

    Welcome to the forum here.

    I'd like you to confirm what operating system you are using, Windows 10 or other operating systems.

    From your description, it seems that you want to install Microsoft Azure Active Directory Module for Windows PowerShell. If yes, I suggest you check whether you have installed Microsoft Online Services Sign-in Assistant for IT Professionals RTW mentioned in the article if you aren't running Windows 10.

    If yes, I suggest you check whether Microsoft .NET Framework 3.5.x is enabled on your computer. If no, you may enable it. You can check the How do you know it worked? part in the article to see if Microsoft .NET Framework 3.5.x can be enabled.

    Meanwhile, PowerShell version 7 and later don't support the Microsoft Azure Active Directory Module for Windows PowerShell module and cmdlets with Msol in their name. For PowerShell version 7 and later, you must use the Microsoft Graph PowerShell SDK. If you are in this scenario, I suggest you refer to the article to install the Microsoft Graph PowerShell SDK and then see the result.

    Thanks for your effort and time.

    Cliff

    Was this answer helpful?

    0 comments No comments