Hello, I am trying to create a vm that will use UEFI and Secure boot with the new powershell cmdlets. With the version 1 cmdlets this was not possible. Does anyone know if this is possible with V2 or are we still required to use the API along with the powershell cmdlets?
Yes, you should be able to do that in the v2 cmdlets. You will want to create a boot config first.
Here is a sample boot config:
$boot=New-NutanixObject BootConfig
$boot.uefi_boot=$true
$boot.secure_boot=$true
$boot.boot_device_type='DISK'
$boot.disk_address=$diskAddress
Â
Then apply that boot config to the VM. Â
New-VM -Name TestBoot -NumVcpus 2 -MemoryMb 8000 -ClusterUUID <UUID>Â -BootConfig $boot
Â
Thanks. This is a great start.
I am trying to add a disk from an image I have. Depending on the purpose of the VM I might have multiple disks from images. What I did in the past was:
$base = 'Server_2019_UEFI'
Â
switch ($vmtype)
    {
      'IIS' {$vmdisks = $base,'IISData','IISLogs'}
      'SQL' {$vmdisks =$base,'SQL-2017' }
      'VM'  {$vmdisks = $base}
    }
        $vmDisk = New-NTNXObject -Name VMDiskDTO
        $diskCloneSpec = New-NTNXObject -Name VMDiskSpecCloneDTO
        IF($VMDisks.count -gt '1') {
          $diskImage = (Get-NTNXImage | Where-object {$_.name -eq $vmdisksi0]})
        }
        ELSE
        {
          $diskImage = (Get-NTNXImage | Where-object {$_.name -eq $vmdisks})
        }
        $diskCloneSpec.vmDiskUuid = $diskImage.vmDiskId
        $vmDisk.vmDiskClone = $diskCloneSpec  Â
      Â
      IF($VMDisks.count -gt '1') {
            Â
             $vmDisk = @($vmDisk)
         Foreach ($disk in $vmdisks){
         IF($disk -ne $VMDisks 0]){
          $AddvmDisk = New-NTNXObject -Name VMDiskDTO
          $AdddiskCloneSpec = New-NTNXObject -Name VMDiskSpecCloneDTO
          $AdddiskImage = (Get-NTNXImage | Where-object {$_.name -eq $disk})
          $AdddiskCloneSpec.vmDiskUuid = $AdddiskImage.vmDiskId
          $AddvmDisk.vmDiskClone = $AdddiskCloneSpec
          $vmDisk += $AddvmDisk
          }
        }
      }
        $vmISODisk = New-NTNXObject -Name VMDiskDTO
        $vmISODisk.isCdrom = $true
        $vmISODisk.isEmpty = $true
Â
Â
So now I am thinking I need to use the:
Â
$vmDisk = New-NutanixObject -Name VMDisk
Â
And then add the $vmdisk.vm_disk_clone property with the UUID from the image in the repository?Â
Correct. To clone you need to get the VM disk UUID first. You might already have that handy. If you don’t, you can grab that by getting the UUID of the image first ‘Get-Image’. Once you have the image UUID get the VM disk UUID with ‘Get-Image -ImageID <image UUID> -IncludeVmDiskId. VM disk image will be listed at vm_disk_id.Â
From there the cloning is strait forward.Â
- Create VMDiskAddressÂ
      $cloneDiskAddress=New-NutanixObject VMDiskAddress
      $cloneDiskAffress.vmdisk_uuid=’<VM Disk UUID>
- Create VMDiskSpecClone
      $vmDiskClone=New-NutanixObject VMDIskSpecClone
      $vmDiskClone.disk_address=$cloneDiskAddress
- Create VMDisk Object
     $vmDisk=New-NutanixObject VMDisk
     $vmDisk.is_cdrom=$false
     $vmDisk.vm_disk_clone=$vmDiskClone
Â
Just throwing this out there as well for instances where you don’t want to clone. To create a net new disk, you will need the storage container UUID. You can grab the UUID with ‘Get-StorageContainer | ConvertTo-Json -depth 6’.
- Â Create the vmDiskCreate spec
     $vmDiskCreate=New-NutanixObject VMDIskSpecCreate
     $vmDiskCreate.storage_container_uuid=’<UUID>’
     $vmDiskCreate.size=’800000’
- Create the vmDisk
     $vmDisk=New-NutanixObject VMDisk
     $vmDisk.is_cdrom=$false
     $vmDisk.disk_address=$diskAddress
     $vmDisk.vm_disk_create=$vmDiskCreate
Â
Thanks again for the help. Very much appreciated.
I noticed 2 things just in case someone comes behind me here. First there is a typo onÂ
Â
$cloneDiskAffress.vmdisk_uuid=’<VM Disk UUID>
It should be
Â
$cloneDiskAddress.vmdisk_uuid=’<VM Disk UUID>
Â
No big deal.
Â
Secondly there is not type VMDIskSpecClone with New-NutanixObject. According to the help there is only:
Available object names are VMDiskAddress, BootConfig, VMDiskSpecCreate, VMDisk, VMNicSpec.
Â
When I try to use it I get an error saying it is not in the dictionary.
I am using version 2.01 of the module. Is there a new version?
Â
Get-Module Nutanix.Prism.PS.Cmds
ModuleType Version   PreRelease Name               Â
----------Â Â Â Â Â -------Â Â Â Â ---------- ----Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Script       2.0.1     Nutanix.Prism.PS.Cmds Â
Good catch on the typo!
Â
The 2.0.1 Modules will work with New-NutanixObject VMDiskSpecClone
Â
Installed Modules:
PS > Get-InstalledModule
Version        Name                 Repository      Description -------        ----                 ----------      -----------
2.0.1         Nutanix.Cli             PSGallery       Nutanix Powershell Commands
2.0.1         Nutanix.Prism.Common         PSGallery       Nutanix Prism Common module
2.0.1         Nutanix.Prism.PS.Cmds        PSGallery       Nutanix Prism Powershell Commands Module
Â
Sample of output:
PS> $vmDiskClone=New-NutanixObject VMDiskSpecClone
PS> $vmDiskClone :
disk_address :  Â
:mage_path :Â Â Â Â
ndfs_filepath :Â Â
minimum_size :Â
minimum_size_mb :
snapshot_group_id. :
container_uuid   :
Yup. It is case sensitive. Didn’t realize.Â
Â
Thanks again for all of the help.
No problem!
Â
Â
first of all you need to connect to cluster:
Connect-NutanixCluster -server 172.16.3.10 -username admin -password $password  –AcceptInvalidSSLCerts
and if you cannot pass the password as a variable , just remove and it will ask you to type the password manually
once you are connected, you will be able to search each cmdlet for the new changes,Â
for example:
New-NutanixObject BootConfig  is changed to New-NutanixObject -Name BootConfig
Â
Â
Regards,
Hello comunity, i need info if these cmdlets are updated or there is new cmdlets for booting configuration?
i am preparing boot configuration for deploying VM with UEFI and SATA combination but those cmdlets are not working for me. I am using latest cmdlets downloaded directly from the Prism Element.
$boot=New-NutanixObject BootConfig
$boot.uefi_boot=$true
$boot.secure_boot=$false
$boot.boot_device_type='DISK'
$boot.disk_address=$diskAddress
Those line are throwing errors…
Thanks and regards
Â
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.