VMware Cloud Community
DhimanLahiri
Contributor
Contributor
Jump to solution

Hard drives created using powerCLI not showing up

Hi,

I created a New Vm using the following code and booted into the BIOS. There I decided to boot from CD and the ISO linked to the CD drive is a windows PE ISO. On booting into WinPE, when I try and do a diskpart by running DISKPART at the command prompt and running list drive

it says "there are no fixed disks to show".

Am I doing something wrong here? Code below:

  1. function to enable/disable boot into BIOS screen

filter Set-VMBIOSSetup

{

param(

$Disable,

$PassThru

)

if($_ -is http://VMware.VimAutomation.Types.VirtualMachine)

{

trap { throw $_ }

$vmbo = New-Object VMware.Vim.VirtualMachineBootOptions

$vmbo.EnterBIOSSetup = $true

if($Disable)

{

$vmbo.EnterBIOSSetup = $false

}

$vmcs = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmcs.BootOptions = $vmbo

($_ | Get-View).ReconfigVM($vmcs)

if($PassThru)

{

Get-VM $_

}

}

else

{

Write-Error "Wrong object type. Only virtual machine objects are allowed."

}

}

$index = 0

  1. Create the virtual machines

1..$vmCount | %{

$vm = New-VM -VMHost $desiredHost -Name "testVm" -Datastore $ds -MemoryMB 8000

$vm | Set-VMBIOSSetup -PassThru

0..1 | %{$vm | New-HardDisk -Datastore $ds -CapacityKB (4*1MB) -Confirm:$false}

$netName = ($vm | Get-NetworkAdapter).NetworkName

0..2 | %{$vm | New-NetworkAdapter -NetworkName $netName -Confirm:$false}

0..2 | %{

$isoPath = '' + ' Installer/' + $myISOPath[$index++]

$vm | New-CDDrive -Confirm:$false -IsoPath $isoPath -StartConnected:$true

}

Start-VM -VM $vm -Confirm:$false

$vm | Get-CDDrive | Set-CDDrive -Connected:$true -Confirm:$false

$index = 0

}

Disconnect-VIServer -Confirm:$false

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Yes, there has been a similar thread about the type of controller that was chosen.

See for the details.

In that thread there is also a link to my script in from .

____________

Blog: LucD notes

Twitter: lucd22


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

What does

Get-VM -Name "testVM" | Get-HardDisk

return when you are the BIOS boot prompt ?

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
DhimanLahiri
Contributor
Contributor
Jump to solution

Hi Luc,

This is what Get-HardDisk returns when the VM boots into the BIOS

Regards

Dhiman

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Hi Dhiman,

The disks are there.

Then I suspect it has to do with the absence of drivers for the virtual controller in WinPE.

See KB1011710 on how you can include drivers for the virtual HW in a WinPE image.

Depending on your OS version, the type of the controller will be different. The sample drivers referenced in the KB are not necessarily the drivers you would need.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
DhimanLahiri
Contributor
Contributor
Jump to solution

Hi Luc,

I seem to have found the problem. It works if I manually create a VM and boot into the WinPE. I check the 2 VM configurations and found that the SCSI controller on the one I was creating via script is BuLogic whereas the VM created manually has an LSI Logic controller.

Can we change the SCSI controller via powercli? I guess we should be able to do this using ReconfigVM but not sure how to go about it.

Regards

Dhiman

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, there has been a similar thread about the type of controller that was chosen.

See for the details.

In that thread there is also a link to my script in from .

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos