You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting an error:
Failed Exception calling "Query" with "1" argument(s): "Exception calling "ExecuteWithResults" with "1" argument(s): "Execute w...
When trying to use Copy-DbaCredential on credentials created by/for replication, which contains square brackets '[', ']' in their name for example on a credential with name like:
[REPL][XXX][XXXX]
Steps to Reproduce
1.) Create a credential on MSSQL which does contain square brackets '[', ']' in it's name, for example:
[REPL][MyDomain\TestAccount][ServerName-ReplicationName]
2) Execute Copy-DbaCredential with source as the server containing mentioned credential.
Please confirm that you are running the most recent version of dbatools
2.1.7
Other details or mentions
Problem seems to be laying in Copy-DbaCredential, Line: 220
$destServer.Query("CREATE CREDENTIAL [$sqlcredentialName] WITH IDENTITY = N'$identity', SECRET = N'$password' $cryptoSQL")
There are used square brackets in front and after $sqlcredentialName instead of using proper QUOTENAME function for escaping.
What PowerShell host was used when producing this error
Not sure if it's correct fix, it's just proposed fix, which works for me.
Because:
$decryptedCredentials items already contain a property .Quotename which is escaped correctly by QUOTENAME function.
One possible fix could be to use the value from .Quotename property instead of $credentialName variable
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Getting an error:
Failed Exception calling "Query" with "1" argument(s): "Exception calling "ExecuteWithResults" with "1" argument(s): "Execute w...
When trying to use Copy-DbaCredential on credentials created by/for replication, which contains square brackets '[', ']' in their name for example on a credential with name like:
[REPL][XXX][XXXX]
Steps to Reproduce
1.) Create a credential on MSSQL which does contain square brackets '[', ']' in it's name, for example:
[REPL][MyDomain\TestAccount][ServerName-ReplicationName]
2) Execute Copy-DbaCredential with source as the server containing mentioned credential.
Please confirm that you are running the most recent version of dbatools
2.1.7
Other details or mentions
Problem seems to be laying in Copy-DbaCredential, Line: 220
$destServer.Query("CREATE CREDENTIAL [$sqlcredentialName] WITH IDENTITY = N'$identity', SECRET = N'$password' $cryptoSQL")
There are used square brackets in front and after $sqlcredentialName instead of using proper QUOTENAME function for escaping.
What PowerShell host was used when producing this error
Windows PowerShell (powershell.exe)
PowerShell Host Version
Name Value
PSVersion 5.1.20348.2110
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.20348.2110
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
SQL Server Edition and Build number
Microsoft SQL Server 2022 (RTM-CU8) (KB5029666) - 16.0.4075.1 (X64)
.NET Framework Version
PSChildName Version
Client 4.8.04161
Full 4.8.04161
Client 4.0.0.0
The text was updated successfully, but these errors were encountered: