Share via

Import-Module DataGateway fails with "Import-Module: Could not load file or assembly. The system cannot find the file specified."

Burak Aktas 0 Reputation points
2024-11-24T18:24:09.12+00:00

Hi there,

PowerShell newbie here. I created an AWS EC2 instance with Windows AMI, and upgraded its PowerShell from 5.1 to 7.4 to install and run DataGateway via its related cmdlets. Import-Module DataGateway -Force command fails with error message;

Import-Module: Could not load file or assembly 'System.Management.Automation, Version=7.4.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Here are the steps I followed;

C:\Users\Administrator> Install-Module DataGateway -Force
WARNING: The version '3000.244.48' of module 'DataGateway' is currently in use. Retry the operation after closing the applications.

C:\Users\Administrator> Import-Module DataGateway -Force
Import-Module: Could not load file or assembly 'System.Management.Automation, Version=7.4.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

Can this be because there are multiple module paths returning duplicate DataGateway modules?


C:\Users\Administrator> Get-Module DataGateway* -ListAvailable
    
Directory: C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     3000.244.…            DataGateway                         Core      {Add-DataGatewayCluster, Add-DataGatewayClusterMember, Add-DataGatewayClusterUser, Get-AllDataGatewayClustersAndDatasourcesStatus…}
Binary     3000.244.…            DataGateway.Profile                 Core      {Connect-DataGatewayServiceAccount, Disconnect-DataGatewayServiceAccount, Get-DataGatewayAccessToken, Resolve-DataGatewayError…}
    
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     3000.244.…            DataGateway                         Core      {Add-DataGatewayCluster, Add-DataGatewayClusterMember, Add-DataGatewayClusterUser, Get-AllDataGatewayClustersAndDatasourcesStatus…}
Binary     3000.244.…            DataGateway.Profile                 Core      {Connect-DataGatewayServiceAccount, Disconnect-DataGatewayServiceAccount, Get-DataGatewayAccessToken, Resolve-DataGatewayError…}

Additionally, PSModulePath env path has multiple powershell module paths makes me thinking this is the root cause of the problem.

C:\Users\Administrator> echo $env:PSModulePath
C:\Users\Administrator\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\WindowsPowerShell\Modules;

Any help appreciated. Thanks!

Windows for business | Windows Server | User experience | PowerShell

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.