6.1.1

Table Of Contents
Sample PowerCLI Script to Perform Operations on Linux Desktop
Machines
You can customize and use the following sample script to perform operations on any number of Linux
desktop machines.
To copy and paste the script content without page breaks, use the HTML version of this topic, available
from the Horizon 6 documentation page at https://www.vmware.com/support/pubs/view_pubs.html.
Script Input
This script reads one input file, which is described in “Input File for the Sample PowerCLI Scripts to Deploy
Linux Desktops,” on page 25. This script also interactively asks for the following information:
n
IP address of the vCenter Server
n
Administrator login name for the vCenter Server
n
Administrator password for the vCenter Server
n
Action to perform, which can be power-on, power-off, shut down guest, restart machine, or delete
virtual machine
Script Content
<#
.DESCRIPTION
The Tool supports:
1. Power off VMs
2. Power on VMs
3. Shutdown VMs
4. Restart VMs
5. Restart VM guest
6. Delete VMs from Disk
.NOTES
#>
#--------------------- Functions --------------------
function IsVMExists ($VMExists)
{
Write-Host "Checking if the VM $VMExists Exists"
[bool]$Exists = $false
#Get all VMS and check if the VMs is already present in VC
$listvm = Get-vm
foreach ($lvm in $listvm)
{
if($VMExists -eq $lvm.Name )
{
$Exists = $true
Write-Host "$VMExists is Exist"
}
}
return $Exists
}
Chapter 3 Bulk Deployment of Horizon 6 for Linux Desktops
VMware, Inc. 35