Open gracious80 opened 4 years ago
Hi @gracious80 - thanks for the issue! I've updated the code slightly, now using a cmdlet to get the SQL Instance Id for the target rather than trying to form some sort of web request. Hopefully this helps with your issues. Pull down the new master and let me know if this helps...
Also, ensure that TargetDBConnectionString within the config matches that of what you would see when connecting to SSMS - and of course that you have proper credentials saved ( sa should work)
thanks for your help. it worked for the first error but it is not working for database credentials. i checked following manually which is working but not sure why it is not working in main script.
#Get Credentials for SQL
$CredFile = $IdentityPath + $database.TargetDBSQLCredentials
$Creds = Import-Clixml -Path $CredFile
#Get Logical Filename for Primary File
#-=MWP=- - may need to rejig for sa usage
#-=MWP=- - need to look at connectionstring if instance is just MSSQL
$results = Invoke-Sqlcmd -Query "SELECT name FROM sys.database_files WHERE type_desc = 'ROWS';" -ServerInstance $database.TargetDBConnectionString -Database $database.TargetDBName -Credential $Creds
I am getting following error.
Creating SQL database snapshot of DBA_ToolsLMT Invoke-Sqlcmd : Cannot open database "DBA_ToolsLMT" requested by the login. The login failed. Login failed for user 'sa'. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:87 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:87 char:16
... $results = Invoke-Sqlcmd -Query "SELECT name FROM sys.database_files ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Invoke-Sqlcmd : Cannot open database "DBA_ToolsLMT" requested by the login. The login failed. Login failed for user 'sa'. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:93 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:93 char:16
... $results = Invoke-Sqlcmd -Query "CREATE DATABASE [$dbsnapshot] ON (n ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Running dbcc checkdb on DBA_ToolsLMT SQL Snapshot.. Invoke-Sqlcmd : Cannot open database "DBA_ToolsLMT_SS" requested by the login. T he login failed. Login failed for user 'sa'. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:97 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:97 char:16
... $results = Invoke-Sqlcmd -Query "dbcc checkdb(); select @@spid as Se ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Invoke-Sqlcmd : Cannot drop the database 'DBA_ToolsLMT_SS', because it does not exist or you do not have permission. Msg 3701, Level 11, State 1, Procedure , Line 1. At E:\DBA\Rubrik_CHKDB\RubrikSQLHealthCheckNew\ExecuteDBCC.ps1:102 char:16
================================================================
Hi this might the syntax problem at my end. can you please help me. .\ExecuteDBCC.ps1 -ConfigFile .\config\databases.json -EnvironmentFile .\environment\environment.json -IdentityPath .\identity
Rubrik Status: Connected to 100.100.100.100 Beginning Live Mount of DBA_Tools on abc200.com New-RubrikDatabaseMount : Cannot process argument transformation on parameter 'T argetInstanceId'. Cannot convert value to type System.String. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:78 char:69
Get-RubrikRequest : Cannot bind argument to parameter 'id' because it is an empt y string. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:82 char:35
Live Mount of DBA_Tools completed! Live Mount name is DBA_Tools_257_LiveMount Creating SQL database snapshot of DBA_Tools_257_LiveMount Invoke-Sqlcmd : Cannot open database "DBA_Tools_257_LiveMount" requested by the login. The login failed. Login failed for user 'Rubrik_sql'. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:91 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:91 char:16
... $results = Invoke-Sqlcmd -Query "SELECT name FROM sys.database_files ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Invoke-Sqlcmd : Cannot open database "DBA_Tools_257_LiveMount" requested by the login. The login failed. Login failed for user 'Rubrik_sql'. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:98 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:98 char:16
... $results = Invoke-Sqlcmd -Query "CREATE DATABASE [$dbsnapshot] ON (n ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Running dbcc checkdb on DBA_Tools_257_LiveMount SQL Snapshot.. Invoke-Sqlcmd : Cannot open database "DBA_Tools_257_LiveMount_SS" requested by t he login. The login failed. Login failed for user 'Rubrik_sql'. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:103 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:103 char:16
QLHealthCheck-master\ExecuteDBCC.ps1:98 char:16
... $results = Invoke-Sqlcmd -Query "CREATE DATABASE [$dbsnapshot] ON (n ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Running dbcc checkdb on DBA_Tools_257_LiveMount SQL Snapshot.. Invoke-Sqlcmd : Cannot open database "DBA_Tools_257_LiveMount_SS" requested by t he login. The login failed. Login failed for user 'Rubrik_sql'. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:103 char:16
Invoke-Sqlcmd : Incorrect syntax was encountered while parsing ''. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:103 char:16
... $results = Invoke-Sqlcmd -Query "dbcc checkdb(); select @@spid as Se ...
CategoryInfo : ParserError: (:) [Invoke-Sqlcmd], BatchParserException
FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Manageme nt.PowerShell.GetScriptCommand
Invoke-Sqlcmd : Cannot drop the database 'DBA_Tools_257_LiveMount_SS', because i t does not exist or you do not have permission. Msg 3701, Level 11, State 1, Procedure , Line 1. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:110 char:16
DBCC Complete, removing DBA_Tools_257_LiveMount Remove-RubrikDatabaseMount : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the i nput and its properties do not match any of the parameters that take pipeline in put. At E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master\ExecuteDBCC.ps1:115 char:86
Results of dbcc checkdb for DBA_Tools Live Mount
================================================================ Script Complete! PS E:\DBA\Rubrik_CHKDB\PowerShell-RubrikSQLHealthCheck-master\PowerShell-RubrikS QLHealthCheck-master>
databases.json { "Databases": [ { "SourceDBName": "DBA_Tools", "SourceDBInstance": "MSSQLSERVER", "SourceDBServer": "abc200", "TargetDBName": "DBA_Tools_LiveMount", "TargetDBServer": "abc200", "TargetDBInstance": "MSSQLSERVER", "TargetDBConnectionString": "abc200", "TargetDBSQLCredentials": "abc200-creds.xml",
}
environment.json
{ "rubrikServer": "100.100.100.100", "rubrikCred": "rubrikCreds.xml" }