Get rid of copy and paste code in installer/ and unify them.

The powershell scripts had lots of duplication. Make the unified
code instead.