VMware Cloud Community
schiguru
Contributor
Contributor

Creating partitions using Powershell

Hi,

I have a requirement where I have to create two disks for a VM and then install the Windows OS on the primary hard-drive. This works fine for Win 2003 but fails with Win 2008 witht he error:

'Windows cannot find a system volume that meets requirements for installation.'

The reason for this is, post Win 2003, if there are 2 or more raw hard-drvies, Windows requires the raw hard drives to be partitioned before installing the OS.

My question: Is there a way to create a partition on the drive using Powershell ? I could not find any 'cmdlet', so was wondering if there was an other way.

Thanks.

0 Kudos
3 Replies
mikefoley
VMware Employee
VMware Employee

One way to skin this cat is build a bootable ISO image (Linux or UBCD4WIN) with VMware tools pre-installed. Boot the new VM with this ISO and use Powershell to run a script on the guest that creates the partitions.

It shouldn't be too hard with UBCD4WIN if you want to stick with an all-Windows solution.

mike

mike

0 Kudos
halr9000
Commander
Commander

You have vCenter? I think in this scenario I'd much prefer to use a template with the guest already pre-installed and sysprepped. You'd save a lot of time this way.



[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator

Author of the book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
0 Kudos
LucD
Leadership
Leadership

It's a kind of "the chicken and the egg" question.

A template would be great but ideally I would like to automate that as well.

A PowerShell/PowerCLI only solution could be:

1) create your new guest with New-Vm. Let's call it VM1.

2) add the hard disk of your new guest (VM1) to another guest (VM2) that has for example Windows XP installed. You can use the Add-HD function from

3) use the Invoke-VMScript on VM2 to start a PS script that will use diskpart to create the partition. See Tobias's blog entry Embedding native commands on how to do this.

4) remove the hard disk from VM2

5) start VM1 with the correct ISO attached to the CD/DVD drive

If you're interested I could thinker together a PS script.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos