Archives for June 2014

Get random element of an array using Powershell

I needed to return a random element of an array using powershell. I have used this method while building simple wireless passwords for a company. This is a simplified version, first lets create the array with Blue and Green in it.

How do I access the array then, simple just do $array[$x] where $x is random. So how do we get a valid integer as $x?

Lets just make sure that we are working with an array and not just a string, cast the array variable as array. [array]$array.

The end result

Why complicate with [array]

Q: I simplified the command by removing the ([array]), and it still works. So why did you add that extra?

A: If you or your friends are running an older powershell version (2 or less), they you cant run .count on a string. If you try it, it will return nothing.


Move all FSMO roles to the local domain controller using Powershell

I upgraded one domain controller in my home active directory and needed to move all the FSMO the new domain controller. So since I’m really lazy and like quick solutions I check what powershell could help me with. And since I know it should live in the ActiveDirectory module I decided to list all move commands in that module.

[Read more…]

Tablet hardware keys cheatcard

So since I have a few tablets now I realized there are some differences to how you enter bios and such. So this is a list of mine and others I have played with.

Dell Venue Pro 8


  1. Power on the device
  2. Press and hold the volume up (+) button


  1. Power on the device
  2. Press and hold the volume down (-) button

Boot menu:

  1. Power on the device
  2. Press the volume up (+) button quickly and release

Surface Pro 2 (Probably most Microsoft Surfaces)

UEFI settings:

  1. Turn the machine off
  2. Press and hold the volume up (+) button
  3. Power on the device
  4. Just before the Surface logo appears release the volume up button

Boot from USB:

  1. Turn the machine off
  2. Insert the USB memory into the computer, make sure it UEFI bootable.
  3. Press and hold the volume down (-) button
  4. Power on the device
  5. Release the volume up button when the Surface logo appears

Screen capture:

  1. Press and hold Windows button. The button that takes you to the start menu.
  2. Press the volume down key on the left side of the surface
  3. The screen should dark flash for a second to show that it is done.

Getting a FSMO DC to start without replication

So you have just restored your domain controller so that you can do a recovery test or a real recovery. And you notice that the domain controller isn’t working. First you off you might even need to logon using the Directory Restore mode because well you just don’t get in. Then you notice all of those Event id 2092 in the Active Directory log.



This is a security measure implemented by Microsoft. To make sure that a domain controller that hosts a FSMO wont start the FSMO role, without checking if another domain controller has seized the role while the server was down. Consider the following:

  • We loose the current RID master (dc01)
  • We promote (seize) the dc02 to RID master
  • We fix the server dc01

If the check wasn’t done we could have two RID masters until the first replication was completed with dc01. Since having more than one of a FSMO role online at the same time is BAD. This check is good and works most of the time.

So now you are thinking, well my domain only has one domain controller. And it starts just fine, so?? Well Microsoft checks if there are any replication partners, if there aren’t well no need to check for replication.

[Read more…]