This script came about from myself and Dominic trying to automate the Build ISO process.
********************************************************************
#####################################################
#
# Build ISO for PXE Booting
# Requires PowerCLI v5.0
# Requires WinSCP v4.3.x (For SCP to Linux Server)
#
#####################################################
######################################
# Global Vars
######################################
$VibListOutput = "D:\scripts\ScriptOutput\CustomESXi5.0_VibList_Output_$((get-date).toString('MM-dd-yyyy_hh.mmtt')).txt"
$CustomESXiISO = "D:\esxi_custom\CustomBuildISOs\ESXi5.0_$((get-date).toString('MM-dd-yyyy_hh.mmtt')).iso"
######################################
# Adding Software Depots
######################################
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\ESXi500-201109001.zip
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\EMCPower.VMWARE.5.7.b173.zip
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\hp-esxi5.0uX-bundle-1.0-20.zip
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\hp-HPUtil-esxi5.0-bundle-1.0-23.zip
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\hp-nmi-esxi5.0-bundle-2.0-11.zip
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\be2net-4.0.355.1-offline_bundle-487292.zip
Add-EsxSoftwareDepot -DepotUrl D:\esxi_custom\lpfc820-8.2.2.105.34-offline_bundle-476869.zip
######################################
# Create/Clone Custom Profile
######################################
Get-EsxImageProfile
New-EsxImageProfile -CloneProfile ESXi-5.0.0-20110904001-standard -Name "ESXi5.0Custom"
######################################
# Get Package List to find what you
# want to add into the profile
# - Run in PowerCLI Shell seperatly -
######################################
#Get-EsxSoftwarePackage
######################################
# Add Packages into Profile
######################################
Add-EsxSoftwarePackage -ImageProfile VIG -SoftwarePackage hpnmi,char-hpcru,char-hpilo,hponcfg,hpbootcfg,hp-smx-provider,powerpath.plugin.esx,powerpath.lib.esx,powerpath.cim.esx,net-be2net,scsi-lpfc820
######################################
# Verify Package Contents
#####################################
Get-EsxImageProfile VIG | select-object -ExpandProperty VibList | Out-File $VibListOutput
######################################
# Creat Custom ISO
#####################################
Export-EsxImageProfile ESXi5.0Custom -FilePath $CustomESXiISO -ExportToIso
######################################
# SCP ISO to vmaor14p501mhp
# for Linux PXE
# - Important: Login to Linux PXE
# with Username/Password in WinSCP GUI and
# Cache the Password
#####################################
# SCP Process VARs
$ScriptDir = "d:\scripts\"
$CustomBuildISOs = "d:\esxi_custom\CustomBuildISOs\"
$Resources = "C:\Program Files (x86)\WinSCP"
$LinuxPXEHost = "user@linux.host"
# Create SCP Script File
&{
trap{Continue}
[array]$Script = "Open $LinuxPXEHost"
$Script += "option batch on"
$Script += "option confirm off"
$Script += "lcd $CustomBuildISOs"
$Script += "cd /root"
$Script += "put $CustomESXiISO"
$Script += "close"
$Script += "exit"
# Dump script to file
$Script | out-file -filePath "$ScriptDir\scp2pxe.txt" -encoding "ASCII"
# SCP CustomBuildISO
$Process = [diagnostics.process]::Start("$Resources\winscp.com","$($Record.Session) /console /script=$ScriptDir\scp2pxe.txt")
$Process.WaitForExit()
}
##############################
# Email log file
##############################
#send-mailmessage -SmtpServer "SMTPServerName" `
#-from "CustomESXi Build ISO <DoNotReply@noreply.gov>" `
#-to "Somebody <somebody@somewhere.gov>" `
#-subject "CustomESXi Build ISO" `
#-body "CustomESXi5.0 Build ISO VibList attached. Custom ISO SCP'd to LinuxPXE Host."
#-Attachment $VibListOutput
##############################
No comments:
Post a Comment