@@ -223,10 +223,10 @@ foreach($sqlDatabase in $srv.databases)
223223 foreach ($MsgType2 in $db.ServiceBroker.ServiceContracts )
224224 {
225225 # Script out objects for each DB
226- $strmyBrokerMsgTypeName = $MsgType2.Name
227- $strmyBrokerMsgType = $fixedDBName + " _Broker_Contract_" + $strmyBrokerMsgTypeName + " .sql"
226+ $strmyBrokerContractName = $MsgType2.Name
227+ $strmyBrokerContract = $fixedDBName + " _Broker_Contract_" + $strmyBrokerContractName + " .sql"
228228 $strmyBObj = $MsgType2.script ()
229- $output_path = $DB_Broker_output_path + " \" + $strmyBrokerMsgType
229+ $output_path = $DB_Broker_output_path + " \" + $strmyBrokerContract
230230
231231 # Not system Objects
232232 if (! $MsgType2.IsSystemObject )
@@ -246,13 +246,13 @@ foreach($sqlDatabase in $srv.databases)
246246 foreach ($MsgType3 in $db.ServiceBroker.Queues )
247247 {
248248 # Script out objects for each DB
249- $strmyBrokerMsgTypeName = $MsgType3.Name
250- $strmyBrokerMsgType = $fixedDBName + " _Broker_Queue_" + $strmyBrokerMsgTypeName + " .sql"
249+ $strmyBrokerQueueName = $MsgType3.Name
250+ $strmyBrokerQueue = $fixedDBName + " _Broker_Queue_" + $strmyBrokerQueueName + " .sql"
251251 try
252252 {
253253 $strmyBObj = $MsgType3.script ()
254254
255- $output_path = $DB_Broker_output_path + " \" + $strmyBrokerMsgType
255+ $output_path = $DB_Broker_output_path + " \" + $strmyBrokerQueue
256256
257257 # Not system Objects
258258 if (! $MsgType3.IsSystemObject )
@@ -268,7 +268,7 @@ foreach($sqlDatabase in $srv.databases)
268268 }
269269 catch
270270 {
271- # Write-Output "Skipping system queue $strmyBrokerMsgTypeName "
271+ # Write-Output "Skipping system queue $strmyBrokerQueueName "
272272 }
273273 }
274274
@@ -277,10 +277,11 @@ foreach($sqlDatabase in $srv.databases)
277277 foreach ($MsgType4 in $db.ServiceBroker.Services )
278278 {
279279 # Script out objects for each DB
280- $strmyBrokerMsgTypeName = $MsgType4.Name
281- $strmyBrokerMsgType = $fixedDBName + " _Broker_Service_" + $strmyBrokerMsgTypeName + " .sql"
280+ $strmyBrokerServiceName = $MsgType4.Name
281+ $strmyBrokerService = $fixedDBName + " _Broker_Service_" + $strmyBrokerServiceName + " .sql"
282282 $strmyBObj = $MsgType4.script ()
283- $output_path = $DB_Broker_output_path + " \" + $strmyBrokerMsgType
283+ $output_path = $DB_Broker_output_path + " \" + $strmyBrokerService
284+
284285
285286 # Not system Objects
286287 if (! $MsgType4.IsSystemObject )
@@ -300,13 +301,14 @@ foreach($sqlDatabase in $srv.databases)
300301 foreach ($MsgType5 in $db.ServiceBroker.Routes )
301302 {
302303 # Script out objects for each DB
303- $strmyBrokerMsgTypeName = $MsgType5.Name
304- $strmyBrokerMsgType = $fixedDBName + " _Broker_Route_" + $strmyBrokerMsgTypeName + " .sql"
304+ $strmyBrokerRouteName = $MsgType5.Name
305+ $strmyBrokerRoute = $fixedDBName + " _Broker_Route_" + $strmyBrokerRouteName + " .sql"
305306 $strmyBObj = $MsgType5.script ()
306- $output_path = $DB_Broker_output_path + " \" + $strmyBrokerMsgType
307+ $output_path = $DB_Broker_output_path + " \" + $strmyBrokerRoute
307308
308- # Not system Objects
309- if (! $MsgType5.IsSystemObject -and $MsgType5.Name -ne " AutoCreatedLocal" )
309+
310+ # Skip system Objects
311+ if ($MsgType5.Name -ne " AutoCreatedLocal" )
310312 {
311313 # Only create path if something to write
312314 if (! (test-path - path $DB_Broker_output_path ))
@@ -316,6 +318,7 @@ foreach($sqlDatabase in $srv.databases)
316318 $strmyBObj | out-file $output_path - Force - encoding ascii
317319 $anyfound = $true
318320 }
321+
319322 }
320323
321324if ($anyfound - eq $true )
0 commit comments