0

I'm installing dbatools to run on a Ubuntu Container.

Error:

 Could not import /usr/local/share/powershell/Modules/dbatools/1.1.142/bin/smo/coreclr/System.Security.SecureString.dll : Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'System.Security.SecureString, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."
 At /usr/local/share/powershell/Modules/dbatools/1.1.142/internal/scripts/libraryimport.ps1:150 char:21
 +                     [Reflection.Assembly]::LoadFrom($assemblyPath)
 +                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
 + FullyQualifiedErrorId : FileLoadException
  
 Import-Module : The specified module '/usr/local/share/powershell/Modules/dbatools/1.1.142/bin/dbatools.dll' was not loaded because no valid module file was found in any module directory.
 At /Test5.ps1:12 char:1
 + Import-Module dbatools
 + ~~~~~~~~~~~~~~~~~~~~~~
 + CategoryInfo          : ResourceUnavailable: (/usr/local/share/po\u202642/bin/dbatools.dll:String) [Import-Module], FileNotFoundException
 + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

My Dockerfile

From myImage

RUN pwsh -Command 'Set-PSRepository -Name PSGallery -InstallationPolicy Trusted'

RUN pwsh -command "Install-Module sqlserver -Scope AllUsers -Force"
RUN pwsh -command "Install-Module dbatools -Scope AllUsers -Force"
RUN pwsh -command "Get-module -ListAvailable -Name 'dbatools'"
RUN pwsh -command "Get-module -ListAvailable -Name 'sqlserver'"

COPY Test5.ps1 .

CMD [ "pwsh", "Test5.ps1"]

myImage contains the requred setup to run powershell on ubuntu 20.

Test5.ps1

Import-Module dbatools

What do I need to do to make my powershell module work without needing to be manually imported?

THANKS!

Ten Uy
  • 111
  • 1
  • 2
  • 11
  • Try running `Import-Module /path/to/System.Security.SecureString.dll` and see if you get a better error. Also try checking the status of `[system.security.securestring]` or `[system.security.securestring].Assembly` in your container. If nothing else, open an issue here for it: https://github.com/dataplat/dbatools/issues – Cpt.Whale Nov 11 '22 at 19:24

1 Answers1

0

dbatools raise this as an issue and to be fix on 2.0.

Ten Uy
  • 111
  • 1
  • 2
  • 11