Uninstall MS Exchange Server 2016

Today, I read through the support thread of one guy who ended up paying to a customer support from MS to get rid of a nasty Exchange server.

And, I must admit, it is not something that can be removed with ease.

! The following manual will help you to annihilate the Exchange server and its data. If you still wish to save some of it, don’t use this instruction.

Let’s say, you need to completely wipe it out from the machine – and uninstaller always fails to remove so-called Default Mailboxes.

There are a few types of them which you need to take care of manually:

Get-Mailbox -Archive | Disable-Mailbox
Get-Mailbox -Monitoring | Disable-Mailbox
Get-Mailbox -AuditLog | Disable-Mailbox
Get-Mailbox -PublicFolder | Disable-Mailbox

Now,  you need to get rid of “-Arbitration” mailbox but it is not as easy as previous cases. Firstly, go and find out the name of your Mailbox Database:


It will show you something like “Mailbox Database 12212842873428”. Use the entire name, no0t just a number! Now, you can remove all Arbitration mailboxes:

Get-MailboxDatabase -Database "NAME FROM THE PREVIOUS COMMAND" -Arbitration | Disable-Mailbox -Arbitration

It will fail at the last mailbox which is using some default address book (are you still following the actual meaning of these error messages? Not sure if it is physically possible…)

So, to remove the default Offline Address Book we need to get its name. At least, this is what the support says. Forget the support, use the wild card!

Remove-OfflineAddressBook -Identity "*"

And finally:

Get-Mailbox -Database "NAME" -Arbitration | Disable-Mailbox -Arbitration -DisableLastArbitrationMailbox

Phew, that was it. Now, nothing can stop you from wiping out the Exchange server from your server.


Extract ISO without mounting it

I’ve spent a lot of time looking for the easiest way to unpack ISO image file under Linux without mounting it (it requires root privileges).

The solution you may find over the Internet describes various tools – one option is to install p7zip and p7zip-plugins (which is OK) or other custom tools which I wouldn’t like to depend on in my configuration.

However, there is not much information about bsdtar that is an excellent replacement of the common tar tool which also allows unpacking ISO images with:

$ bsdtar xvf image.iso

Ansible: loops and registering results of commands

Ansible has a great feature of registering results of a performed step. But recently I stumbled upon a need to do it against actions from a loop and then using the registered result in the next steps which are also looped. Most often, it can be used to perform some action only in case if a previous action changed a file.

Firstly, we register `action_state` variable. Its sub-dictionary `results` contains attribute `changed` which can be accessed as `action_state.results.changed`. Now, we need to get it into use in the next looped step. It can be done with ease using `with_together` operator:

- name: copy a file
    src: '{{ source }}'
    dest: '{{ target }}'
  with_items: yourlist
  when: item.state == 'present'
  register: action_state

- name: create .ssh dir if file changed in the previous step
  sudo_user: '{{ item.0.user }}'
    state: directory
    path: '/home/{{ item.0.user }}/.ssh'
    mode: 0700
  - yourlist
  - action_state.results
  when: item.1.changed and item.0.state == 'present'

Here, for the `yourlist` we copied some files to a target machine (i.e. public keys to some temp location) in the loop and then for each of the files performed an action only if a file was changed.

Books for getting more power with PowerShell

When you look at available PowerShell books, almost every link at the Internet points you to the infamous:

Jones, Don, and Jeffrey T. Hicks. Learn Windows PowerShell 3 in a Month of Lunches. Manning, 2013.

This book is indeed very good and professionally written. However, it doesn’t explain some basics which are very important for understanding PS features. It feels like you are being dragged into a dark and scary forest of this bloody PowerShell. On the serious note, I could say that this book was written by PS gurus who can barely walk in the shoes of ordinary Linux users or SW engineers.

Instead of it, I would recommend checking out this one:

Santos, Donabel. “PowerShell for SQL Server essentials.” (2015).

It has it all, plus puts it into SQL server context. Delicious!

I very much like the author’s style and the way of approaching main concepts. He just explains it to you as to a colleague without trying to impress you with his deep knowledge of the subject.

Great job, Mr. Santos!

Removing unused Docker containers

Those who work with Docker know how fast is free space disappearing, especially, in case you are experimenting with some new features and don’t pay much attention to cleaning up. As the result, a lot of empty untagged containers can eat tens of gigabytes of space.

Here is the one-liner I found to be very useful for removing old stuff:

docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm

Actually, I’m not the one who came up with this answer, but I spent a few hours trying different commands and googling for the answer.

Here is the full Docker cheat sheet that I bumped into and found it being quite good itself:


Using renderables in Buildbot custom steps

Currently, I’m being widely involved in customization of Buildbot instances. Many questions arise, but no answers are usually available on the Web.

Recently, I designed a custom build step which by the definition needed to work with values from properties passed to it on the init time. The challenge was to make it understanding everything that can theoretically be passed – build properties (IProperty), plain values etc.

In this case, we can use ‘renderables’ list to specify mapping from variables that can contain properties to variables that are used to store rendered values.

We can use passed values without caring to handle it as property or some other renderable. Buildbot does it automatically

class MyStep(BuildStep):
    renderables = ['renderable1' , 'renderable2']

    def __init__(self, passed_var1, passed_var2):
        self.renderable1 = passed_var1
        self.renderable2 = passed_var2

Invoke the step in the build factory as:

MyStep(util.Prop(property1), util.Prop(property2))


MyStep('actual value 1', 'actual value 2')

Now we can use passed values simply as without caring to handle it as property or some other renderable. Buildbot does it automatically.

Getting style attributes of web-elements using Selenium IDE

Let’s assume you have an element of a web-page that contains an attribute, that you need to have access to, within its style property. Even more, this attribute is changed by your application, and you want to test whether it now corresponds to a correct value, or there is a mistake.

Element’s HTML:

<span id="imgStats" class="imgStats" style="background-image: url("yoursite.com/image.png");">

What we are looking for is a comparison of  yoursite.com/image.png to an actual value.

Solution: access it by xPath and use getXpathCount() method of SeleniumIDE in PHPUnit:

$this->assertEquals("1", $this->getXpathCount("xpath=id('imgStats')[@style='background-image: url(\"/yoursite.com/img.png\");']"));

This method counts a number of elements that have a particular xpath. In this case it is expected to be equal to 1. If you have any other attributes in style, you must specify them in the selector. Otherwise it won’t work. Also take into account a syntax of this expression, it took one hour to figure out a correct sequence of all these semicolons and brackets 🙂