Tag : powercli

VMware How To: Create A Custom ESXi Bootable ISO With Third Party Drivers

PowerCLIIf you have wondered how you can go about creating your own ESXi image complete with any drivers, such as storage controller drivers or network card drivers then you can use PowerCLI imagebuilder to achieve this.
This is helpful if the standard ESXi image is causing a purple screen of death (PSOD) when trying to boot up ESXi.


To do this you will need a copy of PowerCLI, you can download the v5.5 from the VMware website.
Once installed, set the execution policy to remote signed.

Set-ExecutionPolicy RemoteSigned

Now you are ready to start building your custom image following the steps below.

Import the VMWare software and vendor depot
Add-EsxSoftwareDepot C:\Name_of_ESXi_Offline_Bundle.zip
Add-EsxSoftwareDepot C:\Driver_Name_of_VIB.zip

Find the name of the driver we added
Get-EsxSoftwarePackage -Vendor Vendor_Name

Find the name of the image profile we want to copy. This will list all the image profiles available within the offline bundle.
Get-EsxImageProfile | Select Name

Copy the image profile that we need and give it a name
New-EsxImageProfile -cloneprofile ESXi-5.5.x.x-standard -name New_Name

Add the VIB to the image, <name> is the name of the driver (E.g. qlogic-nic)
Add-EsxSoftwarePackage -imageprofile name -softwarepackage <name>

Export to a new .ISO
Export-EsxImageProfile -imageprofile name -exporttoiso -filepath “c:\custom.imagebuilder.iso”

Boot from the ISO and you have your own custom ESXi image.

PowerCLI: Remap vCD Network When Duplicate Exists

Ok so it’s a bit of a long title.

When you import a virtual machine into vCloud Director from the underlying vCenter Server you can remap the network as mentioned in my previous blog post Import VMs from vCenter to vCloud Director using PowerCLI.
This works great up to the point when you have more than one vApp network with the same name, something that grows increasingly likely the bigger your vCD environment gets.

There is a way around this issue.  You can get PowerCLI to query the vApp that you are trying to connect the imported VM to and use the output of the vApp network name in the remap command.  Let me show you.

First connect PowerCLI to the vCD cell and the underlying vCenter.

$ciserver = vclouddirector.domain.com
$viserver = vcenter.domain.com

Connect-VIServer -Server $viserver
Connect-CIServer -Server $ciserver

Now specify the vApp name

$civapp = vApp_Name

Then specify the vApp network name so you can call it when you get the VM to do the remap.

$cinetwork = get-civapp $civapp | Get-CIVAppNetwork Network_Name

Finally run the remap command

Get-CINetworkAdapter | Set-CINetworkAdapter -vappnetwork $cinetwork -IPaddressAllocationMode Pool -Connected $True

To simplify this further you can run this all as part of a script to query all the VMs that are added to the vApp and remap all their networks to use the same one.  To use this just copy and paste it into a text editor and save it as a .PS1 file.

$ciserver = 'vclouddirector.domain.com'
$viserver = 'vcenter.domain.com'

Connect-VIServer -Server $viserver
Connect-CIServer -Server $ciserver

<$civapp = 'vApp_Name'
$cinetwork = get-civapp $civapp | Get-CIVAppNetwork 'Network_Name'
foreach ($civm in $civms) {
$civm | Get-CINetworkAdapter | Set-CINetworkAdapter -vappnetwork $cinetwork -IPaddressAllocationMode Pool -Connected $True

You can add an extra layer to this by specifying a variable to query Organisation Virtual Datacenter first then add this to the $cinetwork variable as follows.

$orgvdc = OrgvDC_Name
$cinetwork = get-orgvdc $orgvdc | get-civapp $civapp | Get-CIVAppNetwork Network_Name