Unable to run New-VM after changing to vcenter 6.5

Hi All,

I recently set up a cluster system in vcenter 6.5. Previously I was running 6.0, with a bunch of powercli scripting to create/manage/delete vms. Everything had been running fine up until trying to execute on 6.5

I'm currently running PowerCLI 6.5, Powershell 5, and the correct .net and others required for powershell. Here is what I'm getting:

C:\Path\To\Somewhere> new-vm -Name test -VMHost $vmhost

new-vm : 12/20/2017 3:43:09 PM  New-VM          Object reference not set to an instance of an object.

At line:1 char:1

+ new-vm -Name test-vm -VMHost $vmhost

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

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

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

Note, $vmhost is the object got by Get-VMHost myhostname, I've the following variations as well:

new-vm -Name test-andy -VMHost $vmhost.name

new-vm -Name test-andy -VMHost myvmhost_string

new-vm -Name test-andy -VMHost (Get-VMHost myhostname)

Also, the getting that vmhost works just fine.

Am I missing something here? Previously I just passed the esx name as a string with no issues. As well, I've tried to use -ResourcePool, using a valid pool that is returned from Get-ResourcePool, same error result as above.

Thanks for any help in advance.

0 Kudos
1 Reply

Is that vSphere environment running with applied licenses?

Can you create other objects in that environment (New-Folder, New-Datacenter...)?

Is there more info on the exception?

Can you check what is $error[0].Exception, or execute the cmdlet in a Try-Catch construct


    New-VM -Name test-vm -VMHost $vmhost -ErrorAction Stop







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

0 Kudos