How to Create a VM to use with ESX managed by Altiris

Creating a New Virtual Machine to Use with an ESX Server Managed by Altiris

#!/bin/bash
#Scripting VMware Power Tools: Automating Virtual Infrastructure
Administration
#Creates a new Virtual Machine for use with Altiris
#####USER MODIFICATION################
#VMNAME is the name of the new virtual machine
#VMOS specifies which Operating System the virtual machine will have
#DESTVMFS is the path to the VMFS partition of the VMDK file
#VMDSIZE is the size of the Virtual Disk File being created ex (500mb) or
(10g)
#####################################
VMNAME="vm_name"
VMOS="winNetStandard"
VMMEMSIZE="256"
DESTVMFS="vmhba0:6:0:1 #Must use the vmhba path
VMDSIZE="10g"
#####END MODIFICATION#####
LOG="/opt/altiris/deployment/adlagent/bin/logevent"
$LOG -l:1 -ss:"Creating VMX Configuration File"
mkdir /home/vmware/$VMNAME
exec 6>&1
exec 1>/home/vmware/$VMNAME/$VMNAME.vmx
# write the configuration file
echo #!/usr/bin/vmware
echo config.version = '"'6'"'
echo virtualHW.version = '"'3'"'
echo memsize = '"'$VMMEMSIZE'"'
echo floppy0.present = '"'TRUE'"'
echo usb.present = '"'FALSE'"'
echo displayName = '"'$VMNAME'"'
echo guestOS = '"'$VMOS'"'
echo suspend.Directory = '"'/vmfs/vmhba0:0:0:5/'"'
echo checkpoint.cptConfigName = '"'$VMNAME'"'
echo priority.grabbed = '"'normal'"'
echo priority.ungrabbed = '"'normal'"'
echo ide1:0.present = '"'TRUE'"'
echo ide1:0.fileName = '"'auto detect'"'
echo ide1:0.deviceType = '"'cdrom-raw'"'
echo ide1:0.startConnected = '"'FALSE'"'
echo floppy0.startConnected = '"'FALSE'"'
echo floppy0.fileName = '"'/dev/fd0'"'
echo Ethernet0.present = '"'TRUE'"'
echo Ethernet0.connectionType = '"'monitor_dev'"'
echo Ethernet0.networkName = '"'Network0'"'
echo draw = '"'gdi'"'
echo
echo scsi0.present = '"'TRUE'"'
echo scsi0:1.present = '"'TRUE'"'
echo scsi0:1.name = '"'vmhba0:0:0:5:$VMNAME.vmdk'"'
echo scsi0:1.writeThrough = '"'TRUE'"'
echo scsi0.virtualDev = '"'vmxlsilogic'"'
echo
# close file
exec 1>&-
# make stdout a copy of FD 6 (reset stdout), and close FD6
exec 1>&6
exec 6>&-
$LOG -l:1 -ss:"VMX Configuration File Created Successfully"
#Change the file permissions
chmod 755 /home/vmware/$VMNAME/$VMNAME.vmx
#Create the Virtual Disk
$LOG -l:1 -ss:"Creating Virtual Disk"
vmkfstools -c $VMDSIZE vmhba0:0:0:5:$VMNAME.vmdk
$LOG -l:1 -ss:"Virtual Disk Created Successfully"
#Register the new VM
$LOG -l:1 -ss:"Registering VMX Configuration"
#Registering .vmx Configuration"
vmware-cmd -s register /home/vmware/$VMNAME/$VMNAME.vmx
$LOG -l:1 -ss:"VMX Initialization Completed Successfully"
#Starting the Virtual Machine
$LOG -l:1 -ss:"Starting the Virtual Machine"
vmware-cmd /home/vmware/$VMNAME/$VMNAME.vmx start
$LOG -l:1 -ss:"Virtual Machine Started"
$LOG -l:1 -ss:"Passing control to Altiris for PXE boot and install of VM"