i get bellow error when i call Invoke-Sqlcmd, see below full error log PS>TerminatingError(Import-Module): "Could not load file or assembly 'file:///C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.1.18209\Microsoft.SqlServer.Management.PSSnapins.dll' or one of its dependencies. Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
TerminatingError(Import-Module): "Could not load file or assembly 'file:///C:\Program Files\WindowsPowerShell\Modules\SqlServer\21.1.18209\Microsoft.SqlServer.Management.PSSnapins.dll' or one of its dependencies. Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))" PS>TerminatingError(): "The 'Invoke-Sqlcmd' command was found in the module 'SqlServer', but the module could not be loaded. For more information, run 'Import-Module SqlServer'." The 'Invoke-Sqlcmd' command was found in the module 'SqlServer', but the module could not be loaded. For more information, run 'Import-Module SqlServer'. Invoke-Sqlcmd : The 'Invoke-Sqlcmd' command was found in the module 'SqlServer', but the module could not be loaded. Fo r more information, run 'Import-Module SqlServer'. At C:\ECC\DataImporter.ps1:17 char:1
- Invoke-Sqlcmd -Query "EXEC dbo.Toshiba_ECC_Export" -ServerInstance "S ...
-
+ CategoryInfo : ObjectNotFound: (Invoke-Sqlcmd:String) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
$ErrorActionPreference = "Stop"
$dbcredential = Import-CliXml -Path "db.cred"
Start-Transcript -Path "C:\ECC\Logs\Log.txt" -Append
Write-Host "---------------ECC DATA IMPORTER------------------"
Write-Host "---------------------START---------------------"
Write-Host "---------------------Stopping old processes---------------------"
$CommandLines = Get-CimInstance -Query "SELECT * from Win32_Process WHERE CommandLine LIKE '%eccimport%'"
foreach ($command in $CommandLines)
{
Stop-Process -id $Command.processId -Force
}
Invoke-Sqlcmd -Query "EXEC dbo.Toshiba_ECC_Export" -ServerInstance "ServerXXXX" -Database "DatabaseXXX" -querytimeout 0 -Credential $dbcredential |
Export-Csv -NoTypeInformation -Path "Import_ECC.csv" -Encoding UTF8
$MyFile = Get-Content .\Import_ECC.csv
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines(".\Import_ECC_ENCODED.csv", $MyFile, $Utf8NoBomEncoding)
Start-Sleep -s 2
$destination = ".\Archive\Import_ECC_{0:d}.csv" -f (Get-Date)
Copy-Item ".\Import_ECC_ENCODED.csv" -Destination $destination
Start-Sleep -s 2
Write-Host "Import_ECC.csv was created."
Write-Host $destination "was created."
Write-Host "Uploading to ECC".
$test = java -jar ECCImport35.jar -o
Write-Host $test
Write-Host "----------------------END---------------------"
Write-Host " "
Write-Host `