Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ErrorActionPreference = "Stop"
- $ServiceBusNamespace = "PurpleLizard"
- Import-Module ServiceBus
- $thisPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
- Write-Host "Looking for Microsoft.ServiceBus.dll"
- $assemblyFile = Get-ChildItem -Path $thisPath\..\packages -Filter 'Microsoft.ServiceBus.dll' -Recurse | Select-Object -Last 1
- Write-Host "Loading " + $assemblyFile.FullName
- Add-Type -Path $assemblyFile.FullName
- $localUser = [Environment]::UserName
- try
- {
- $namespaces = Get-SBClientConfiguration
- $namespaces = $namespaces -like "*$ServiceBusNamespace*"
- if($namespaces -eq $FALSE -or $namespaces.Count -eq 0) {
- Write-Host "Namespace doesn't exist. Creating it."
- New-SBNamespace -Name $ServiceBusNamespace -ManageUsers $localUser
- } else {
- Write-Host "Namespace $ServiceBusNamespace already exists."
- }
- }
- catch
- {
- Write-Host "Namespace may not exist. Creating it."
- New-SBNamespace -Name $ServiceBusNamespace -ManageUsers $localUser
- }
- #Write-Host "Configuring Shared Access Signature connection string..."
- #New-Item "C:\NimbusServiceBusConnectionString.txt" -Type File -Force -Value (Get-SBAuthorizationRule -NamespaceName $ServiceBusNamespace -Name "RootManageSharedAccessKey").ConnectionString
- $connectionString = Get-SBClientConfiguration -Name $ServiceBusNamespace
- # Note: we delete the topics and queues here because deleting the namespace only marks it for deletion and doesn't
- # actually remove it, so we can't re-create it again immediately.
- Write-Host "Connecting to $connectionString"
- $nsm = [Microsoft.ServiceBus.NamespaceManager]::CreateFromConnectionString($connectionString)
- Write-Host "Deleting Queues..."
- $nsm.GetQueues() | foreach {
- Write-Host "Deleting " + $_.Path
- $nsm.DeleteQueue($_.Path)
- }
- Write-Host "Deleting Topics..."
- $nsm.GetTopics() | foreach {
- Write-Host "Deleting " + $_.Path
- $nsm.DeleteTopic($_.Path)
- }
- $debugMode = Get-SBRuntimeSetting -Name DebugMode
- $includeExceptionDetails = Get-SBRuntimeSetting -Name IncludeExceptionDetails
- Write-Host "IncludeExceptionDetails = ${includeExceptionDetails}"
- if (($debugMode.Value -eq $false) -or ($includeExceptionDetails.Value -eq $false)) {
- Write-Host "Configuring Service Bus host to use DEBUG mode..."
- Set-SBRuntimeSetting -Name DebugMode -Value True
- Set-SBRuntimeSetting -Name IncludeExceptionDetails -Value True
- Write-Host "Restarting the Service Bus farm. This may take a minute or two..."
- Stop-SBFarm
- Start-SBFarm
- } else {
- Write-Host "The Service Bus is already in DEBUG mode. Nothing to do here."
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement