Setting Up for Linux Desktops

Table Of Contents
if (!(Test-Path $csvFile))
{
write-host -ForeGroundColor Red "CSV File not found"
exit
}
#-----------------------------------------------------
Functions------------------------------------------------------------------
function GetSourceInstallerMD5()
{
$agentInstallerPath = Convert-Path $agentInstaller;
$md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
$md5HashWithFormat =
[System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($agentInstallerPath)));
$md5Hash = ($md5HashWithFormat.replace("-","")).ToLower();
return $md5Hash;
}
#-----------------------------------------------------
Main------------------------------------------------------------------
#Get installer MD5Sum
$installerMD5Hash = GetSourceInstallerMD5;
#Connect to vCenter
$VC_Conn_State = Connect-VIServer $vcAddress -user $vcAdmin -password $vcPassword
if([string]::IsNullOrEmpty($VC_Conn_State))
{
Write-Host 'Exit since failed to login vCenter'
exit
}
else
{
Write-Host 'vCenter is connected'
}
#Read input CSV file
$csvData = Import-CSV $csvFile
$destFolder = "/home/$guestUser/"
#Handle VMs one by one
foreach ($line in $csvData)
{
"`n-----------------------------------------------------"
$VMName = $line.VMName
write-host -ForeGroundColor Yellow "VM: $VMName`n"
$cmd = "rm -rf VMware-*-linux-*"
Write-Host "Run cmd '$cmd' in VM '$VMName' with user '$guestUser'"
RunCmdViaSSH -VM_Name $VMName -User $guestUser -Password $guestPassword -Cmd $cmd
#Upload installer tar ball to Linux VM
Write-Host "Upload File '$agentInstaller' to '$destFolder' of VM '$VMName' with user '$guestUser'"
UploadFileViaSSH -VM_Name $VMName -User $guestUser -Password $guestPassword -LocalPath
$agentInstaller -DestPath $destFolder
Setting Up Horizon 7 for Linux Desktops
VMware, Inc. 106