Advertisement
Guest User

Untitled

a guest
May 24th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. $ErrorActionPreference = "Stop"
  2. $ServiceBusNamespace = "PurpleLizard"
  3.  
  4. Import-Module ServiceBus
  5.  
  6. $thisPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
  7.  
  8. Write-Host "Looking for Microsoft.ServiceBus.dll"
  9. $assemblyFile = Get-ChildItem -Path $thisPath\..\packages -Filter 'Microsoft.ServiceBus.dll' -Recurse | Select-Object -Last 1
  10. Write-Host "Loading " + $assemblyFile.FullName
  11. Add-Type -Path $assemblyFile.FullName
  12.  
  13. $localUser = [Environment]::UserName
  14.  
  15. try
  16. {
  17. $namespaces = Get-SBClientConfiguration
  18. $namespaces = $namespaces -like "*$ServiceBusNamespace*"
  19. if($namespaces -eq $FALSE -or $namespaces.Count -eq 0) {
  20. Write-Host "Namespace doesn't exist. Creating it."
  21. New-SBNamespace -Name $ServiceBusNamespace -ManageUsers $localUser
  22. } else {
  23. Write-Host "Namespace $ServiceBusNamespace already exists."
  24. }
  25. }
  26. catch
  27. {
  28.  
  29. Write-Host "Namespace may not exist. Creating it."
  30. New-SBNamespace -Name $ServiceBusNamespace -ManageUsers $localUser
  31. }
  32.  
  33. #Write-Host "Configuring Shared Access Signature connection string..."
  34. #New-Item "C:\NimbusServiceBusConnectionString.txt" -Type File -Force -Value (Get-SBAuthorizationRule -NamespaceName $ServiceBusNamespace -Name "RootManageSharedAccessKey").ConnectionString
  35.  
  36. $connectionString = Get-SBClientConfiguration -Name $ServiceBusNamespace
  37. # Note: we delete the topics and queues here because deleting the namespace only marks it for deletion and doesn't
  38. # actually remove it, so we can't re-create it again immediately.
  39. Write-Host "Connecting to $connectionString"
  40. $nsm = [Microsoft.ServiceBus.NamespaceManager]::CreateFromConnectionString($connectionString)
  41. Write-Host "Deleting Queues..."
  42. $nsm.GetQueues() | foreach {
  43. Write-Host "Deleting " + $_.Path
  44. $nsm.DeleteQueue($_.Path)
  45. }
  46.  
  47. Write-Host "Deleting Topics..."
  48. $nsm.GetTopics() | foreach {
  49. Write-Host "Deleting " + $_.Path
  50. $nsm.DeleteTopic($_.Path)
  51. }
  52.  
  53. $debugMode = Get-SBRuntimeSetting -Name DebugMode
  54. $includeExceptionDetails = Get-SBRuntimeSetting -Name IncludeExceptionDetails
  55. Write-Host "IncludeExceptionDetails = ${includeExceptionDetails}"
  56. if (($debugMode.Value -eq $false) -or ($includeExceptionDetails.Value -eq $false)) {
  57. Write-Host "Configuring Service Bus host to use DEBUG mode..."
  58. Set-SBRuntimeSetting -Name DebugMode -Value True
  59. Set-SBRuntimeSetting -Name IncludeExceptionDetails -Value True
  60. Write-Host "Restarting the Service Bus farm. This may take a minute or two..."
  61. Stop-SBFarm
  62. Start-SBFarm
  63. } else {
  64. Write-Host "The Service Bus is already in DEBUG mode. Nothing to do here."
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement