我正在安装在Ubuntu容器上运行的dbattools。
错误:
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/pou202642/bin/dbatools.dll:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
我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包含在ubuntu 20上运行powershell所需的设置。
Test5.ps1
Import-Module dbatools
我需要做些什么才能使我的powershell模块工作而不需要手动导入?
谢谢!
dbattools将此作为一个问题提出,并将在2.0中修复。