@@ -131,103 +131,103 @@ else
131
131
$ResourceGroupName = $DS_ResourceGroupName
132
132
}
133
133
134
- foreach ($ResourceGroup in $ResourceGroupName )
134
+ foreach ($ResourceGroup in $ResourceGroupName )
135
+ {
136
+ if ($DS_ServerName -eq " " )
137
+ {
138
+ $ServerName = Get-AzureRmSqlServer - ResourceGroupName $ResourceGroup | select - ExpandProperty ServerName
139
+ }
140
+ else
141
+ {
142
+ $ServerName = $DS_ServerName
143
+ }
144
+
145
+ foreach ($Server in $ServerName )
135
146
{
136
- if ($DS_ServerName -eq " " )
147
+ if ($DS_DatabaseName -eq " " )
137
148
{
138
- $ServerName = Get-AzureRmSqlServer - ResourceGroupName $ResourceGroup | select - ExpandProperty ServerName
149
+ $DatabaseName = Get-AzureRmSqlDatabase - ResourceGroupName $ResourceGroup - ServerName $Server | select - ExpandProperty DatabaseName
139
150
}
140
151
else
141
152
{
142
- $ServerName = $DS_ServerName
153
+ $DatabaseName = $DS_DatabaseName
143
154
}
144
155
145
- foreach ($Server in $ServerName )
156
+ foreach ($Database in $DatabaseName )
146
157
{
147
- if ($DS_DatabaseName -eq " " )
158
+ if ($Database -eq " master " )
148
159
{
149
- $DatabaseName = Get-AzureRmSqlDatabase - ResourceGroupName $ResourceGroup - ServerName $Server | select - ExpandProperty DatabaseName
160
+ continue ;
161
+ }
162
+
163
+ if ($DS_SyncGroupName -eq " " )
164
+ {
165
+ $SyncGroupName = Get-AzureRmSqlSyncGroup - ResourceGroupName $ResourceGroup - ServerName $Server - DatabaseName $Database | select - ExpandProperty SyncGroupName
150
166
}
151
167
else
152
168
{
153
- $DatabaseName = $DS_DatabaseName
169
+ $SyncGroupName = $DS_SyncGroupName
154
170
}
155
171
156
- foreach ($Database in $DatabaseName )
172
+ foreach ($SyncGroup in $SyncGroupName )
157
173
{
158
- if ($Database -eq " master" )
159
- {
160
- continue ;
161
- }
162
-
163
- if ($DS_SyncGroupName -eq " " )
164
- {
165
- $SyncGroupName = Get-AzureRmSqlSyncGroup - ResourceGroupName $ResourceGroup - ServerName $Server - DatabaseName $Database | select - ExpandProperty SyncGroupName
166
- }
167
- else
174
+ $Logs = Get-AzureRmSqlSyncGroupLog - ResourceGroupName $ResourceGroup `
175
+ - ServerName $Server `
176
+ - DatabaseName $Database `
177
+ - SyncGroupName $SyncGroup `
178
+ - starttime $StartTime `
179
+ - endtime $EndTime ;
180
+
181
+ if ($Logs.Length -gt 0 )
168
182
{
169
- $SyncGroupName = $DS_SyncGroupName
170
- }
171
-
172
- foreach ($SyncGroup in $SyncGroupName )
183
+ foreach ($Log in $Logs )
173
184
{
174
- $Logs = Get-AzureRmSqlSyncGroupLog - ResourceGroupName $ResourceGroup `
175
- - ServerName $Server `
176
- - DatabaseName $Database `
177
- - SyncGroupName $SyncGroup `
178
- - starttime $StartTime `
179
- - endtime $EndTime ;
180
-
181
- if ($Logs.Length -gt 0 )
182
- {
183
- foreach ($Log in $Logs )
184
- {
185
- $Log | Add-Member - Name " SubscriptionId" - Value $SubscriptionId - MemberType NoteProperty
186
- $Log | Add-Member - Name " ResourceGroupName" - Value $ResourceGroup - MemberType NoteProperty
187
- $Log | Add-Member - Name " ServerName" - Value $Server - MemberType NoteProperty
188
- $Log | Add-Member - Name " HubDatabaseName" - Value $Database - MemberType NoteProperty
189
- $Log | Add-Member - Name " SyncGroupName" - Value $SyncGroup - MemberType NoteProperty
185
+ $Log | Add-Member - Name " SubscriptionId" - Value $SubscriptionId - MemberType NoteProperty
186
+ $Log | Add-Member - Name " ResourceGroupName" - Value $ResourceGroup - MemberType NoteProperty
187
+ $Log | Add-Member - Name " ServerName" - Value $Server - MemberType NoteProperty
188
+ $Log | Add-Member - Name " HubDatabaseName" - Value $Database - MemberType NoteProperty
189
+ $Log | Add-Member - Name " SyncGroupName" - Value $SyncGroup - MemberType NoteProperty
190
190
191
- # Filter out Successes to Reduce Data Volume to OMS
192
- # Include the 5 commented out line below to enable the filter
193
- # For($i=0; $i -lt $Log.Length; $i++ ) {
194
- # if($Log[$i].LogLevel -eq "Success") {
195
- # $Log[$i] =""
196
- # }
197
- # }
191
+ # Filter out Successes to Reduce Data Volume to OMS
192
+ # Include the 5 commented out line below to enable the filter
193
+ # For($i=0; $i -lt $Log.Length; $i++ ) {
194
+ # if($Log[$i].LogLevel -eq "Success") {
195
+ # $Log[$i] =""
196
+ # }
197
+ # }
198
198
199
199
200
200
201
- }
201
+ }
202
202
203
203
204
- $json = ConvertTo-JSON $logs
204
+ $json = ConvertTo-JSON $logs
205
205
206
206
207
207
208
- Post- OMSData - customerId $customerId - sharedKey $sharedKey - body ([System.Text.Encoding ]::UTF8.GetBytes($json )) - logType $logType
209
- if ($result -eq 200 )
210
- {
211
- Write-Host " Success"
212
- }
213
- if ($result -ne 200 )
214
- {
215
- throw
208
+ Post- OMSData - customerId $customerId - sharedKey $sharedKey - body ([System.Text.Encoding ]::UTF8.GetBytes($json )) - logType $logType
209
+ if ($result -eq 200 )
210
+ {
211
+ Write-Host " Success"
212
+ }
213
+ if ($result -ne 200 )
214
+ {
215
+ throw
216
216
@"
217
- Posting to OMS Failed
218
- Runbook Name: DataSyncOMSIntegration
217
+ Posting to OMS Failed
218
+ Runbook Name: DataSyncOMSIntegration
219
219
"@
220
- }
221
- }
220
+ }
222
221
}
223
222
}
224
223
}
225
224
}
225
+ }
226
226
227
227
228
228
229
- Set-AzureRmAutomationVariable - ResourceGroupName $AC_ResourceGroupName `
230
- –AutomationAccountName $AC_AccountName `
231
- - Name $AC_LastUpdatedTimeVariableName `
232
- - Value $EndTime `
233
- - Encrypted $False
229
+ Set-AzureRmAutomationVariable - ResourceGroupName $AC_ResourceGroupName `
230
+ –AutomationAccountName $AC_AccountName `
231
+ - Name $AC_LastUpdatedTimeVariableName `
232
+ - Value $EndTime `
233
+ - Encrypted $False
0 commit comments