Setting Up for Linux Desktops

Table Of Contents
Sample Script to Perform Operations on Linux Virtual Machines
You can customize and use the following sample script to perform operations on multiple Linux virtual
machines (VMs). The operations include powering on, powering o, shuing down, restarting, and deleting
the VMs.
This script can delete virtual machines from vCenter Server but not from View.
To copy and paste the script content without page breaks, use the HTML version of this topic, available from
the Horizon 7 documentation page at hps://www.vmware.com/support/pubs/view_pubs.html.
Script Input
This script reads one input le, which is described in “Input File for the Sample PowerCLI Scripts to Deploy
Linux Desktops,” on page 69. 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-o, shut down guest, restart VM, restart VM guest,
or delete VM.
n
The wait time, in seconds, between operations on the VMs.
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 GetInput
{
Param($prompt, $IsPassword = $false)
$prompt = $prompt + ": "
Write-Host $prompt -NoNewLine
[Console]::ForegroundColor = "Blue"
if ($IsPassword)
{
$input = Read-Host -AsSecureString
$input =
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStrin
gToBSTR($input))
}
else
{
Chapter 8 Bulk Deployment of Horizon 7 for Manual Desktop Pools
VMware, Inc. 97