All good things must come to an end. Sometimes, users become ex-users. Here’s a quick-and-dirty way to check.
One notable line here is:
With AD, the second bit from the right is the enable/disabled one. -BAnd is short for ‘binary AND’. It doesn’t matter what the other bits in the UserAccountControl property says, the second bit from the right is all we care about. The –BAnd returns either 2 (the value of 0x010) or 0 (the value of 0x0).