A recent change in the SqlServer PowerShell module has given me a headache this week. I’m running the module with Azure DevOps in a pipeline that is triggering an Azure deployment script within a network-integrated container instance.
System.IO.FileNotFoundException: Could not load file or assembly
The problem this error.
Workaround
This change causes my Invoke-Sqlcmd command to fail, which was luckily already covered on Stack Overflow. As a temporary measure, I am downgrading to the previous module to keep my pipeline working. However, I haven’t found out yet if this will be a permanent change for this module.
# Set the SQL Server module version
$moduleVersion = '22.3.0'
# Install if not already present
if (-not (Get-Module -ListAvailable -Name SqlServer | Where-Object { $_.Version -eq $moduleVersion })) {
Install-Module -Name SqlServer -RequiredVersion $moduleVersion -Force -Scope CurrentUser
}
# Load the module
Import-Module SqlServer -RequiredVersion $moduleVersion