Archive for February, 2007
Virtual machine copying with PowerShell
Believe it or not, PowerShell is more than just fun and games. You can even do productive things with it! A common scenario I run into is the need to create a new virtual machine. Usually I want to base it on one I’ve already created and I want it to join a domain. There are a couple issues that I run in to:
- Duplicate SID Error
- Too many clicks
The first problem can be solved with a free tool that Microsoft has released called NewSID. Running that will give my virtual a unique SID so that it can be added to the domain.
Now for the second problem..too many clicks! Renaming a machine and adding it to the domain takes almost 2 minutes and a nearly infinite number of clicks and keystrokes…or maybe not. At any rate, it’d be great to simplify this process. Enter PowerShell.
Rename a Computer and Join Domain
$comp = get-wmiobject Win32_ComputerSystem $comp.Rename("newComputerName","password","administrator") $comp.JoinDomainOrWorkGroup("MYDOMAIN","domainPassword","MYDOMAIN\domainAdmin",$null,3)
Add a call to NewSID, wrap those delicious lines in a function and you are well on your way to renaming a virtual and joining a domain in fewer keystrokes. Its so easy you might even find yourself creating new virtuals just to run it again.
5 comments