Open
Description
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Exception: Couldn't import C:\Program Files\WindowsPowerShell\Modules\dbatools.library\2024.4.12\core\lib\win-sqlclient\Microsoft.Data.SqlClient.dll | Assembly with same name is already loaded
Steps to Reproduce
Success in v5
C:\>powershell -noprofile -nologo
PS C:\> $PSVersionTable.PSVersion.ToString()
5.1.19041.4412
PS C:\> Import-Module SqlServer
PS C:\> Import-Module dbatools
# Success
Reverse order succeeds in v.5:
C:\>powershell -noprofile -nologo
PS C:\> $PSVersionTable.PSVersion.ToString()
5.1.19041.4412
PS C:\> Import-Module dbatools
PS C:\> Import-Module SqlServer
# Success
Fails in v.7:
SqlServer first:
C:\>pwsh -noprofile -nologo
PS C:\> $PSVersionTable.PSVersion.ToString()
7.4.2
PS C:\> Import-Module SqlServer
PS C:\> Import-Module dbatools
Exception: Couldn't import C:\Program Files\WindowsPowerShell\Modules\dbatools.library\2024.4.12\core\lib\win-sqlclient\Microsoft.Data.SqlClient.dll | Assembly with same name is already loaded
Fails in reverse from the SqlServer module side:
C:\>pwsh -noprofile -nologo
PS C:\> $PSVersionTable.PSVersion.ToString()
7.4.2
PS C:\> Import-Module dbatools
PS C:\> Import-Module SqlServer
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Add-Type: Assembly with same name is already loaded
Please confirm that you are running the most recent version of dbatools
Get-Module dbatools | Select -ExpandProperty Version | Set-Clipboard
Result:
2.1.16
Other details or mentions
No response
What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe), Windows PowerShell (powershell.exe)
PowerShell Host Version
Desktop:
Name Value
---- -----
PSVersion 5.1.19041.4412
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.4412
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Core:
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0β¦}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SQL Server Edition and Build number
Not applicable
.NET Framework Version
[System.Runtime.InteropServices.RuntimeInformation]::get_FrameworkDescription() | Set-Clipboard
Result:
.NET 8.0.4
Activity