-
-
Notifications
You must be signed in to change notification settings - Fork 857
Description
Before submitting a bug report:
Collect output of following command and paste below:
& {"### PowerShell version:`n$($PSVersionTable | Out-String)"; "`n### dbatools Module version:`n$(gmo dbatools -List | select name, path, version | fl -force | Out-String)"}
- Running latest release of dbatools
- Verified errors are not related to permissions
- Is this bug with
Copy-DbaDatabase? You can replicate it usingBackup-DbaDatabase ... | Restore-DbaDatabase ...
NOTE:
Copy-DbaDatabasewill not work in every environment and every situation. Instead, we try to ensure Backup & Restore work in your environment.
Environmental data
### PowerShell version:
Name Value
---- -----
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.42000
BuildVersion 6.3.9600.19170
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2
### dbatools Module version:
Name : dbatools
Path : E:\DATA\RV\SQLMGMT_V5_DEV\PSDev\PSModules\dbatools\dbatools.psd1
Version : 0.9.775
SQL Server:
Microsoft SQL Server 2014 (SP1-CU4) (KB3106660) - 12.0.4436.0 (X64)
Dec 2 2015 16:09:44
Copyright (c) Microsoft Corporation
Enterprise Edition: Core-based Licensing (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)
<!-- NOTE: If the above information is not provided as a minimum your issue will not be acknowledged -->
## Errors Received
<!-- Provide full output of `$error[0] | Select *` -->
writeErrorStream : True
PSMessageDetails :
Exception : System.Exception: Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. The specified
module could not be found. ---> System.Management.Automation.MethodInvocationException: Exception calling "Export" with "3"
argument(s): "Export failed for Certificate 'TDECert_BaselineDB'. " ---> Microsoft.SqlServer.Management.Smo.FailedOperationException:
Export failed for Certificate 'TDECert_BaselineDB'. ---> Microsoft.SqlServer.Management.Smo.FailedOperationException:
ExecuteNonQuery failed for Database 'master'. ---> System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. The specified module could not be found.
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase,
ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.SqlServer.Management.Common.ServerConnection.GetStatements(String query, ExecutionTypes executionType, Int32&
statementsToReverse)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean
retry)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes
executionType, Boolean retry)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.Certificate.Export(String certificatePath, String privateKeyPath, String encryptionPassword)
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Management.Smo.Certificate.Export(String certificatePath, String privateKeyPath, String encryptionPassword)
at CallSite.Target(Closure , CallSite , Object , Object , Object , Object )
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
--- End of inner exception stack trace ---
TargetObject : [TDECert_BaselineDB]
CategoryInfo : NotSpecified: ([TDECert_BaselineDB]:Certificate) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_export-cert,Stop-Function
ErrorDetails : Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. The specified module could not be
found.
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at Stop-Function, E:\DATA\RV\SQLMGMT_V5_DEV\PSDev\PSModules\dbatools\allcommands.ps1: line 105182
at export-cert, E:\DATA\RV\SQLMGMT_V5_DEV\PSDev\PSModules\dbatools\allcommands.ps1: line 3069
at Backup-DbaDbCertificate<Process>, E:\DATA\RV\SQLMGMT_V5_DEV\PSDev\PSModules\dbatools\allcommands.ps1: line 3086
at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}
<# OUTPUT of $error[0] | select * #>
Steps to Reproduce
/*
Any T-SQL commands involved or used to produce test objects/data.
*/<#
Provide exact (or sanitized) code to reproduce the error
#>After creating certificate, run the following command:
Backup-DbaDbCertificate -SqlInstance $SQL1 -Database master -Certificate $TDEDBCert -Path $Share -EncryptionPassword $cert_sec_pw
Expected Behavior
Actual Behavior
I executed the code in Powershell ISE.
Backup-DbaDbCertificate give an error:
WARNING: [09:12:20][export-cert] TDECert_BaselineDB from [master] on TEST\SQL1 cannot be exported. | Could not load file or assembly 'Microsof
t.SqlServer.BatchParser.dll' or one of its dependencies. The specified module could not be found.
I tried to run the code in Powershell ISE (x86) as well, same error, but it seems that it has problem with SQL Server 2017 assembly:
WARNING: [09:19:00][export-cert] TDECert_BaselineDB from [master] on TEST\SQL1 cannot be exported. | Could not load file or assembly 'Microsof
t.SqlServer.BatchParser, Version=14.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file spec
ified.