VMware Cloud Community
galapow_av
Enthusiast
Enthusiast
Jump to solution

Creating VM from CLI

Hi,

PowerCLI C:\> Get-PowerCLIVersion

PowerCLI Version

----------------

   VMware PowerCLI 6.5 Release 1 build 4624819

---------------

Component Versions

---------------

   VMware Cis Core PowerCLI Component 6.5 build 4624453

   VMware VimAutomation Core PowerCLI Component 6.5 build 4624450

   VMWare ImageBuilder PowerCLI Component 6.5 build 4561891

   VMWare AutoDeploy PowerCLI Component 6.5 build 4561891

   VMware HA PowerCLI Component 6.0 build 4525225

   VMware HorizonView PowerCLI Component 7.0.2 build 4596620

   VMware Licensing PowerCLI Component 6.5 build 4624822

   VMware Storage PowerCLI Component 6.5 build 4624820

   VMware Vds PowerCLI Component 6.5 build 4624695

   VMware vROps PowerCLI Component 6.5 build 4624824

   VMware vSphere Update Manager PowerCLI 6.5 build 4540462

I'm connecting to ESXi which version is

Version:

6.7.0 Update 3 (Build 14320388)

The licence is VMware vSphere 6 Standard

Running:

New-VM -Name master1.loadtest.local -Datastore Esxi23_Raid5_12TB -DiskGB 250 -MemoryGB 24 -NumCPU 12 -DiskStorageFormat Thick

This create the vm but gives:

New-VM : 11/26/2019 1:15:37 PM  New-VM          Exception has been thrown by the target of an invocation.

At line:1 char:1

+ New-VM -Name master1.loadtest.local -Datastore Esxi23_Raid5_12TB -Dis ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-VM], VimException

    + FullyQualifiedErrorId : ViCore_ResultConverter_ConvertOnSuccess_VM_Failed,VMware.VimAutomation.ViCore.Cmdlets.Co

   mmands.NewVM

PowerCLI C:\> Get-VM -Name master1.loadtest.local

Name                 PowerState Num CPUs MemoryGB

----                 ---------- -------- --------

master1.loadtest.... PoweredOff 12       24.000

I would like to change the SCSI controller from Buslogic Parallel to ParaVirtual

PowerCLI C:\> Get-HardDisk -VM master1.loadtest.local

Get-HardDisk : 11/26/2019 1:21:17 PM    Get-HardDisk            Exception has been thrown by the target of an invocation.

At line:1 char:1

+ Get-HardDisk -VM master1.loadtest.local

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-HardDisk], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.

   GetHardDisk

How can I change the scsi controller 0 to Paravirtual from cli?

The default guestOS is windows

how can I change that to CentOS 7 (64bit) from cli?

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Is there a specific reason you are using such an old PowerCLI version?


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

View solution in original post

5 Replies
LucD
Leadership
Leadership
Jump to solution

Is there a specific reason you are using such an old PowerCLI version?


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

galapow_av
Enthusiast
Enthusiast
Jump to solution

No.

Now I found VMware vSphere Command Line Interface 6.7

Let me check with that

0 Kudos
galapow_av
Enthusiast
Enthusiast
Jump to solution

Thanks a lot

PS C:\WINDOWS\system32> Get-PowerCLIVersion

PowerCLI Version

----------------

   VMware PowerCLI 11.5.0 build 14912921

---------------

Component Versions

---------------

   VMware Common PowerCLI Component 11.5 build 14898112

   VMware Cis Core PowerCLI Component PowerCLI Component 11.5 build 14898113

   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.5 build 14899560

VMware vSphere 5.1

This explains how to change after the creation, is it possible to add the ParaVirtual option when executing New-VM ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not with the New-VM cmdlet, but you can do

$vm = New-VM -Name master1.loadtest.local -Datastore Esxi23_Raid5_12TB -DiskGB 250 -MemoryGB 24 -NumCPU 12 -DiskStorageFormat Thick

$ctrl = Get-ScsiController -VM $vm | Set-ScsiController -Type ParaVirtual -Confirm:$false


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

0 Kudos
DCasota
Expert
Expert
Jump to solution

The solution LucD proposed works.

Some similar code for years worked like a charm to modify a newly created VM.

$scsiController = Get-HardDisk -VM $VMName | Select -First 1 | Get-ScsiController

Set-ScsiController -ScsiController $scsiController -Type $scsicontrollertype

As Get-Harddisk -VM $VMname fails on PowerCLI 6.5.1, indeed there were some issues fixed in 6.5.4 VMware PowerCLI Release Notes .

0 Kudos