Capture Code – vSphere Web Client

One of the conveniences of administering VMware solutions is being able to use code to create scripts to perform repetitive tasks or automate processes

One of the vSphere Web Client features that can help those new to the PowerCli is the Capture Code, it basically allows you to list and save the Powercli commands of the actions you are doing with the vSphere Web Client.

To activate it just access the vSphere Web Client, from the Menu select Developer Center

Select Code Capture and enable it by placing the “Enable Code Capture” flag on the right (which turns green)

At this point, a space will appear in our frame where the commands will be listed with some operations, such as Clear and start another, Copy and Download

Where the Download option generates you the ps1 file with the Powercli commands of the recorded operations

To start and stop a recording session you can use the buttons:

Or the red button that appears at the top of the WebClient once “Enable Code Capture” is enabled

Bye

Capture Code – vSphere Web Client

WLS Ubuntu 20.04 – Powercli On Linux and use it for Horizon

Well I want to use my WSL Ubuntu 20.04 to use powercli command to manage old Horizon Version (Flash ko)

  • Start to install all updates on my Ubuntu 20.04

sudo apt-get update

sudo apt-get upgrade

  • Configure source for downlad ed install powercli 

sudo apt-get install curl

 curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add

sudo curl -o /etc/apt/sources.list.d/microsoft.list https://packages.microsoft.com/config/ubuntu/20.04/prod.list

sudo apt-get update

  • Install powershell 

sudo apt-get install powershell

sudo pwsh

Set-PowerCLIConfiguration -InvalidCertificateAction:Ignore

  • Install PowerCli Module

Install-Module -Name VMware.PowerCLI

  • Install the horizon module

Import-Module -Name VMware.VimAutomation.HorizonView

  • Download additional module

For download

Run Example Horizon PowerCLI Scripts (vmware.com)

  • Import Horizon Module

Create Horizon Desktop Pool using PowerCLI – Roderik de Block

PowerCLI-Example-Scripts/New-HVPool.md at master · vmware/PowerCLI-Example-Scripts · GitHub

WLS Ubuntu 20.04 – Powercli On Linux and use it for Horizon

Copy file to VMware Datastore using Powercli

https://kb.vmware.com/s/article/2001041

#Mi collego all’Host ESXi dove devo copiare la ISO
Connect-ViServer <hostname>
#Visualizzo l’elenco dei datastore
Get-Datastore
#Seleziono il datastore che mi interessa
$datastore = Get-Datastore “<nome del datastore>”
#Eseguo il mount del PSDrive sotto ds:
New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root “”
#Lancio la copia
Copy-DatastoreItem -Item c:……Windows2016.iso -Destinatiom ds:ISO

Copy file to VMware Datastore using Powercli