Hi to all, Now I'm deployng a new VM from ovftool connecting with ssh to host and executing the following command: ./ovftool --X:logFile=upload.log --X:logLevel=verbose --noSSLVerify --skipManifestCheck --name="VM_Name" /vmfs/volumes/localdatastore/OVF/master.ovf vi://root:!password@127.0.0.1 I would like to use the same procedure through powercli, is it possibile? NB: I have to execute locally due to connection speed. Regards Federico
You can do the same with Import-VApp.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD, I have found your post but now is unreachable where you reply to use the following varible to poin to local datastore:
$fileName = '[MyDatastore] folder/master.ovf'
$dsName,$filePath = $fileName.Split(']')
$dsName = $dsName.TrimStart('[')
$filePath = $filePath.TrimStart(' ')
$ds = Get-Datastore -Name $dsName
$dcPath = $ds.DatastoreBrowserPath.Split('@')[1].TrimStart('443\').Trimend("\$($dsName)").Replace('\','/')
$url1 = "$($global:DefaultVIServer.ServiceUri.OriginalString.TrimEnd('/sdk'))"
$url2 = "$($filePath)"
$url3 = "dcPath=$($dcPath)"
$url4 = "dsName=$($dsName)"
$url = "$($url1)/$($url2)?$($url3)&$($url4)" $url
On variable $fileName = '[MyDatastore] folder/master.ovf' how can I insert my local datastore?
I try to use:
$vmHosts = Get-VMHost -name $MyHost
$datastore = Get-VMHost $MyHost | Get-Datastore
$datastorename = $datastore.name
but don't know to insert in your variable.
Thanks
Which post is unreachable?
The $fileName variable contains the location of the OVA file on one of your datastores.
In
$fileName = '[MyDatastore] folder/master.ovf'
you need to replace the MyDatastore with the name of your datastore.
Then the folder/master.ovf or folder/master.ova is the path on that datastore where the OVF or OVA resides.
Where did you upload the OVA file?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have the ovf file locally and I need to deploy it locally.
But I have to repeat as request to a lot of different hosts. This is the aim to avoid to use ssh on each host and user a powercli script and connect to vcenter to manage, when requested, the deploy
What do you mean by "locally"?
On your PC?
In that case, have a look at Example 1 of the Import-VApp cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry you have right. On the unique local datastore of the host
What script of mine are you using (the one you said earlier that you can't access)?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Now I'm using ssh on the host an then ./ovftool --X:logFile=upload.log --X:logLevel=verbose --noSSLVerify --skipManifestCheck --name="VM_Name" /vmfs/volumes/localdatastore/OVF/master.ovf vi://root:!password@127.0.0.1 I would like to use powercli, connect to vcenter and then, as you have told me, use import-vapp; ma now I need to convert ovftool commad to import-vapp
I mean which post are you referring to?
Thanks LucD, I have found your post but now is unreachable where you reply to use the following varible to poin to local datastore:
You can install the OVA from a folder on your PC or from a location on a datastore.
Which one do you want to use?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
this post: https://code.vmware.com/forums/2530/vsphere-powercli#538119 from location on a datastore
Ok, that is describing a method to construct the URI to be used when the OVA is sitting on a datastore.
There is a known limitation when you are connected to an ESXi node instead of a vCenter.
See Import-vApp still busted in 11.4?
If you are connected to the vCenter, and have the OVA sitting on a local drive on your PC, you should be able to use Import-VApp.
Are any of these requirements not possible for you?
Which one?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I cannot use my pc due to speed connection on remote host. I will check you link thanks
It would also help if you could list the requirements and restrictions for deploying a VM through an OVA in your environment.
So far I gathered from your replies:
Some questions on that.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have all hosts standalone managed from one vCenter. Every host has already copied on local datastore the ovf file. Now I need to connect to every host through SSH to deploy a new VM and I would to write an interactive powercli script to centralize the execution.
You can automate the SSH session with the help of the Post-SSH module.
See also Use Posh-SSH instead of PuTTY - LucD notes
When connected to the VCSA you can get all ESXi nodes.
And then for each of these, run the command (you used before) through an SSH session.
Something like this.
This assumes the same credentials can be used on each ESXi node.
$cmdSub = @'
./ovftool --X:logFile=upload.log --X:logLevel=verbose --noSSLVerify --skipManifestCheck --name="VM_Name" /vmfs/volumes/localdatastore/OVF/master.ovf vi://root:!password@127.0.0.1
'@
Get-VMHost | ForEach-Object -Process {
$session = New-SSHSession -ComputerName $_.Name -Credential $cred –AcceptKey
$result = Invoke-SSHCommand -SSHSession $session -Command $cmdSub
Remove-SSHSession -SSHSession $session | Out-Null
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Many thanks LucD. But how can apply to a single host without foreach-object, because a would use interactive variables. Something else, on the $cmdsub instead of "vmfs/volumes/localdatastore/OVF/master.ovf" writer some that 'vmfs/volumes/$datastorename/OVF/master.ovf', I mean to replace datastore with a variable. Regards
If you want to run on a single host, use the Get-VMHost with the Name parameter.
For using variables in the $cmdSub see my posts Here string and variable substitution - LucD notes and Here strings and the ExpandString method - LucD notes
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD, unfortunately nothing works beacuse my customer is using a custom SSH port and on NEW-SSHSession use a different is not possibile.
The New-SshSession cmdlet does have a Port parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference