Skip to content

Commit

Permalink
Updated AddTargetGroupMember.ps1 in Azure Automation.
Browse files Browse the repository at this point in the history
  • Loading branch information
nboettcher committed Jan 11, 2018
1 parent c569a4d commit 7222815
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion AddTargetGroupMember.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $sqlCredential = Get-AutomationPSCredential -Name 'SQLCredentials'
$adminSqlServer = Get-AutomationVariable -Name 'SqlServerName'
$adminDatabase = Get-AutomationVariable -Name 'SqlServerDatabase'

$connectionString = "Data Source=" + $adminSqlServer + ";Initial Catalog=ElasticJobs;User ID=" + $sqlCredential.UserName + ";Password=" + $sqlCredential.GetNetworkCredential().Password + ";Connection Timeout=90;ConnectRetryCount=3;ConnectRetryInterval=10;"
$connectionString = "Data Source=" + $adminSqlServer + ";Initial Catalog=ElasticJobs;User ID=" + $sqlCredential.UserName + ";Password=" + $sqlCredential.GetNetworkCredential().Password + ";Connection Timeout=90;"
$connection = New-Object -TypeName System.Data.SqlClient.SqlConnection($connectionString)
$query = "IF NOT EXISTS(SELECT * FROM jobs.target_group_members where target_type = 'SqlDatabase' and [database_name] = '" + $database + "' and target_group_name = '" + $targetGroup + "') EXEC jobs.sp_add_target_group_member @target_group_name = '" + $targetGroup + "', @target_type = 'SqlDatabase', @database_name = '" + $database + "', @server_name = '" + $sqlServer + "'"
$command = New-Object -TypeName System.Data.SqlClient.SqlCommand($query, $connection)
Expand Down

0 comments on commit 7222815

Please sign in to comment.