Wednesday, September 16, 2015

Using Powercli to copy files from your computer to Esxi server

My next article: Powercli Get-Esxcli install VIB files
 
This step by step guide on coping files using Powercli, for this you will have to install powercli on you computer. Open powercli.
Next fire up command connect-viserver to connect your esxi or vCenter, think it as, you are connecting through vsphere client GUI, It will ask for credentials (I am connected here to my esxi directly.)
Then next you will see powercli is connected to esxi server. Now we will be coping file on the datastore, All the datastores are listed under vmstore: or vmstores: drive (This is a drive letter for esxi datastores, think it as your c: or any other drive), to go to datastore directory type

cd vmstore:\ha-datacenter\datastore1


I have only one local datastore on my esxi server and name is Datastore1, To view the list of all datastores you can run command Get-Datastore. I have created new directory, as you can see that is visible on GUI as well.
I have downloaded vib file and kept it on my computer under c:\temp (this is my favorite location to keep my testing stuffs)
Next command I am mounting datastore1 as a mapped drive on powercli, it will be visible on the same only., and my mapped datastore drive volume is vDATA. (also this step is not require but i am showing you it as an extra one, always good to have multiple tricks in your memory, to copy files you will need to use special command which I will be showing next, you can also use vmware drive vmstore: as it is already mapped incase if you want to skip below command)
Get-Datastore datastore1 | New-DatastoreDrive -Name vDATA
I am into datastore now by running command cd vDATA:\VIb, it will change the location of current drive.
Below is the special command to copy files to datastore and vice versa, your powershell native command copy-item will not work as windows and vmware both are different drive providers.
Copy-DatastoreItem -Item c:\Temp\esxui-3015331.vib -Destination vDATA:\VIB
and run dir to verify file has been copied, you can verify the same in GUI client also.
Now we have copied file we will be installing it, for the installation i will be using plink.exe tool, (I tried using Get-EsxCli to install this plain VIB file, tried all the possible parameters but every time it failed, if anyone know the correct parameters or if anyone is successful, suggestions are welcome, Just to add I am able to successfully install offline bundles through Get-Esxcli command Powercli Get-Esxcli install VIB files). Plink.exe is putty tool and I will ssh into esxi, but it will be completely automated.
To use plink we will need to be enable SSH on the server. To enable run below command.
Get-VMHost 192.168.33.21 | Get-VMHostService | Where-Object {$_.Lable -eq 'SSH'} | Start-VMHostService
it will start ssh service on esxi.

 Next i created one text file on c:\temp and written one command. That command is actually going to be executed on esxi server, it will be completely automated. (If you check my earlier blogs, I have used plink tool heavily for the internal configuration which is not possible through GUI or Powercli example: Changing Motd banner and Download logs from esxi server where everything is completely automated through plink.exe) 

As below command is going to be run on esxi, make sure your folder name are proper in caps or small letters as esxi is case sensetive. File name is command.txt containing below command.
esxcli software vib install -v /vmfs/volumes/datastore1/VIb/esxu1-3015331.vib 

I have kept my plink file under c:\windows, this way I don't have to do extra configuration on environment variable, On my powercli console: 
Write-Output "yes" | plink.exe -ssh root@192.168.33.21 -P 22 -pw Computer@1 -m 'c:\temp\command.txt'

Once you execute command you will see message operation finished successfully, not reboot required no need to put server into maintenance mode for this software, and the name of vib which has been installed.
below step you can do earlier as well when you finished coping file, but I prefer in the last what if copied file is corrupted. Remove-PSDrive vDATA will unmap mapped datastore drive.
Vib file i installed was vmware host web client. you can find more on information on about this cool fling from vmware. https://blogs.vmware.com/vsphere/2015/08/introducing-vsphere-host-client-fling.html

Below is the summary from fling website for the ESXi Embedded host client.

Summary

This version of the ESXi Embedded Host Client is written purely in HTML and JavaScript, and is served directly from your ESXi host and should perform much better than any of the existing solutions. Please note that the Host Client cannot be used to manage vCenter. Currently, the client is in its development phase, but we are releasing this Fling to elicit early feedback from our users to help guide the development and user experience that we are creating. As such, the client is not fully featured and only implements a hand full of the most important features. Some of these include:

  • VM operations (Power on, off, reset, suspend, etc).
  • Creating a new VM, from scratch or from OVF/OVA (limited OVA support)
  • Configuring NTP on a host
  • Displaying summaries, events, tasks and notifications/alerts
  • Providing a console to VMs
  • Configuring host networking
  • Configuring host advanced settings
  • Configuring host services
We welcome any feedback and bug reports at this early stage. However, rather than reporting on missing features, we are very much interested in your thoughts on the layout, user experience, and performance of the host client.

Known Issues


  • On ESXi hosts which are assigned a VMware vSphere Hypervisor license, all modification operations will fail silently. We are working on a solution to this issue.
  • On ESXi hosts which have a sub-domain name with large, shared cookies a web console session may fail to initialize. A workaround is to clear cookies or run the host client in an incognito-type window.
  • For ESXi 5.5U2 and prior, and ESXi 6.0 hosts upgraded from any 5.5U2 or prior version, you will get a 503 error returned after visiting https://<esxhost>/ui/. To resolve this issue, please remove the line starting with /ui from /etc/vmware/rhttpproxy/endpoints.conf and restart rhttpproxy with /etc/init.d/rhttpproxy restart
  • For ESXi 5.5 hosts, in-browser consoles are not supported. Please use VMRC to access guest VM consoles.
  • For ESXi 5.5U2 and prior hosts, you must ensure to append a trailing / (forward slash) to the URL after /ui. The URL must be https://<esxhost>/ui/
  • For some Windows guests, send Ctrl-Alt-Del does not work.
Other
If you need an offline bundle of the VIB for use with VUM, you can download it here.




No comments: