VMware Cloud Community
fabricesforzani
Contributor
Contributor

error in new-vm clone powercli 4.01

D:\Program Files\VMware\Infrastructure\vSphere PowerCLI> New-

VM -vmHost "140.104.16.139" -Name clonevcuat -VM chdcvvsp8306 -datastore tg_vmfs

uat03 -location vc_clone

New-VM : 09/03/2010 12:02:47 New-VM Could not find VMHost with name '

140.104.16.139'.

At line:1 char:7

+ New-VM <<<< -vmHost "140.104.16.139" -Name clonevcuat -VM chdcvvsp8306 -data

store tg_vmfs_uat_03 -location vc_clone

New-VM : Value cannot be found for the mandatory parameter VMHost

At line:1 char:7

+ New-VM <<<< -vmHost "140.104.16.139" -Name clonevcuat -VM chdcvvsp8306 -data

store tg_vmfs_uat_03 -location vc_clone

D:\Program Files\VMware\Infrastructure\vSphere PowerCLI>

0 Kudos
4 Replies
alanrenouf
VMware Employee
VMware Employee

The first line of the errors said it couldnt find your host, are you sure you got the name correct ? is it listed if you do a Get-VMHost ?

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
0 Kudos
LucD
Leadership
Leadership

You can pass a name to the -VMHost paramter but not an IP address.

Don't you have name resolution ?

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
LucD
Leadership
Leadership

If you have name resoltion you could do

$hostnameRegEx = [regex]"Name:\s+([\w|http://\.]+)"
$text = nslookup 140.104.16.139
$hostname = $hostnameRegEx.Match($text).Groups[1].Value
New-VM -vmHost $hostname -Name clonevcuat -VM chdcvvsp8306 -datastore tg_vmfs_uat_03 -location vc_clone

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

If you have DNS name resolution you can also do:

$hostname = \[System.Net.Dns]::GetHostbyAddress("140.104.16.139").HostName
New-VM -vmHost $hostname -Name clonevcuat -VM chdcvvsp8306 -datastore tg_vmfs_uat_03 -location vc_clone

Please remove the \ after =. I don't know how to prevent this forum software to insert a link if I don't put the \ there.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos