Import-Module error! Powershell Script 📃

Problem :

“Dealing with Powershell Script in Process Studio? Throws Import-Module error!!"

Import-Module : The specified module 'MSOnline' was not loaded because no valid module file was found in any module directory.At D:\tools\Agents\E3License.ps1:208 char:5+ Import-Module MSOnline+ ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (MSOnline:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Solution :

Try below options:

  1. Keep AE agent on a short path. Say D:\Agents and remove the spaces present in the Agent Path.

  2. Please refer these links and check whether it’s working?

    windows - Import-Module : The specified module 'msonline' was not loaded because no valid module file was found in any module directory - Stack Overflow

    windows - MSOnline can't be imported on PowerShell (Connect-MsolService error) - Stack Overflow

If The script is working fine earlier on AE 5.1.0 wit process studio and agents, but after upgrading AE to 5.4.1 it showing this error with agent from same machine.

Try the below changes in DEV environment:

  • Check the powershell MSOnline module verison on both the machine/server using powershell commands:

    1. Where the script is working fine
    2. Where the script is not working
  • The powershell MSOnline verison on both the machine should match. If the verision is different, then please re-install the same version of MSOnline module(where script is working) on the another machine(where script is not working).

  • After re-installing the powershell module, please check the version again using powershell command prompt. Sometimes the installation gets done but the powershell Modules/Version didn’t get change.

  • If the version didn’t get change after re-installation as well, then contact to your IT team and take a help from them to install the correct powershell version.

  • Install the correct verison of MSOnline module on the agent machine and your issue will get resolved automatically.

  • If this issue gets resolved by updating the MSOnline modules then you can conclude that this issue is not related to an agent or AE version upgrade and it is something related to the Powershell-version/OS or any system-level changes on a current dealing server.

Enjoy the automation with ☞ AutomationEdge!!