Scripting Series – Interesting things you can do with VBScript and Powershell
Posted by Matthew on February 25, 2011
I was recently tasked with creating a script (language was my choice) that can set up a bunch of machines for students undertaking some training using virtual machines. The student servers are not managed by System Center Virtual Machine Manager and may not even be network connected, so the script was going to have to do all the hard work of copying machines and resource files from the USB source, staging them in sensible places, importing the VMs into HyperV and performing some other configuration tasks. As the training was also taking place in a public training centre, It also had to help tear the whole thing down again afterwards, including (in order to protect IP) itself!
Naturally Powershell was a good choice for this task as it can accomplish most of the above without breaking a sweat. Rather than re-invent the wheel, I used James O’ Neill’s fantastic HyperV Module. All I had to deal with now were some other interesting challenges, namely
- Script Self Deletion
- UAC Elevation
- Having 1 Script create multiple other scripts
- Setting up virtual NICs with correct IP information
- Bugs in remove-item preventing files from being deleted correctly and odd behaviour from Copy-Item when moving directories
Across a series of blog posts, I’ll show how i overcame these problems and created a pretty feature rich script for setting up lab environments. Enjoy!
Scripting Series – Interesting things you can do with VBScript and Powershell – Post 1, Self Deletion « .Matthew Long said
[...] Scripting Series – Interesting things you can do with VBScript and Powershell [...]