Closed matt-gantz closed 4 months ago
Update- I started to look closer at what is happening when running Import-Module. It get's the error while loading dlls, so I walked through the code and found I could reproduce the error by attempting to load this dll:
Microsoft.SqlServer.Assessment.Cmdlets.dll
PS C:\WINDOWS\system32> $binaryModulePath = 'C:\Program Files\WindowsPowerShell\Modules\SqlServer\22.1.1\Microsoft.SqlServer.Assessment.Cmdlets.dll'
Unblock-file -Path $binaryModulePath
$binaryModule = Import-Module -Name $binaryModulePath -PassThru
Import-Module : Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The
system cannot find the file specified.
At line:3 char:17
+ $binaryModule = Import-Module -Name $binaryModulePath -PassThru
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
Hi @matt-gantz - this looks like an old problem that was addressed a while back.
What OS are you on? The issue back then was only for people running on some really old OS (Windows Server 2016 maybe?) without NetFx 4.7.2.
The workaround back then was to forcefully include that netstandard
"shim". But since the new v22 module got modernized, NetFx472+ is required... and that should make the need for that DLL go away.
Hi @Matteo-T - Yes this was occurring on Windows Server 2016 and 2012 R2.
It does appear that dotnet 4.8 solves the issue. I feel that this dependency should be listed here: https://www.powershellgallery.com/packages/SqlServer
Do you agree?
Uhm... I don't see anything specific for "OS and .Net dependencies". Those OSes are so old that... I would think by now the world had moved forward. :) If that's not the case and I keeep hearing about this problem, I'll think of something.
Thanks.
I upgraded from 21.1.18256 to 22.1.1, and now I get errors running Invoke-Sqlcmd. I have verified that the newest version has the same behavior.
Also interesting, I get error messages when Importing or Removing the module (even though Get-Module suggests that those commands are successful):
Version info: Windows Server 2012 R2 ; SQL Server 2014 (12.0.6449.1); Powershell 5.1.14409.2001