PS: Windows Server Build PowerCLI

###################################################################################################
#List of Variables:NameScript, OSType, FullName, OrgName, ChangeSid, Type, DnsServer, DnsSuffix, #
# TimeZone, GuiRunOnce, NamingScheme, NamingPrefix, ProductKey, Description, #
# IpMode, IpAddress,SubnetMask, DefaultGateway, AlternateGateway, Dns, Template, #
# EsxHost, Datastore, NumCpu,MemoryMB, NetworkName #
###################################################################################################
#load PowerCLI snap-in
Add-PSSnapin VMware.VimAutomation.Core
#Connect the vCenter
Connect-VIServer -Server <IP Address> -User <UserName> -Password <Password>
#Import the file. Please select the Path
Import-Csv <File Path of the Source CSV> | foreach {
#New-OSCustomizationSpec Creation of new OS Customization spec
New-OSCustomizationSpec -Name $_.NameScript -OSType $_.OSType -Description “$_.Description” -NamingScheme $_.NamingScheme -NamingPrefix $_.NamingPrefix -FullName $_.FullName -OrgName $_.OrgName -ChangeSid -Type $_.type -DnsServer $_.DnsServer -DnsSuffix $_.DnsSuffix -TimeZone $_.TimeZone -Workgroup “Workgroup” -AdminPassword “<Password for Admin>”
Get-OSCustomizationSpec $_.NameScript | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $_.IPAddress -SubnetMask $_.SubnetMask -DefaultGateway $_.DefaultGateway -Dns $_.Dns -AlternateGateway $_.AlternateGateway
New-VM -Name $_.NamingPrefix -Template $_.Template -VMHost $_.EsxHost -Datastore $_.Datastore -OSCustomizationSpec $_.NameScript -Confirm:$false -Location “<Folder Name>”
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s