Over the past couple of weeks I’ve been working on a PC deployment script using PowerShell – the goal is to run the script, walk away, then come back and the computer should be completely set up.
My original version included a lot of proprietary/confidential information as the commands were hard-coded into the script. Obviously, that’s not very good for distribution or customization internally. Thus began the effort to make the script entirely customizable through XML and CSV files.
The basic premise is that there are three stages of deployment – with a reboot in-between each one. This allows changes, such as computer name, domain join, windows updates, etc. to be applied. However, as the PC reboots, it needs to re-initialize the script and resume from where it left off. I ran into a few struggles with the re-initialization/persistent powershell scripts on my virtual machine which were solved through this post (http://www.codewrecks.com/blog/index.php/2017/07/18/hyper-v-and-windows-autologon/). So, the deployment might look something like this:
Stage One: Create user accounts, install software, reboot.
Stage Two: Windows Updates, set computer name, domain join, reboot.
Stage Three: Windows Updates (yes, again!), set power configuration, re-apply the license key (dell manufacturing line issues), copy files from a network share, reboot.
The current version of the script can be found on Github. Right now, I’m debugging the script (there are definitely kinks to be worked out), but the proof of concept is enough to be considered viable.
Disclaimer: As a human, I will inevitably make mistakes and get things wrong. If you notice an error, or have a better solution, please let me know!