vSphere 5.0實(shí)踐:使用PowerCLI部署虛擬機(jī)
使用克隆及模板的方式來(lái)部署虛擬機(jī),但不管是從模板部署還是對(duì)虛擬機(jī)進(jìn)行克隆,都只能一對(duì)一,不能一對(duì)多。如果需要部署N臺(tái)虛擬機(jī)的話,兩種方法都不是那么有效。那么是否有更快捷的方法呢?當(dāng)然有,用腳本PowerCLI。接下來(lái)我就用PowerCLI來(lái)同時(shí)部署多臺(tái)虛擬機(jī)。
Step1:自定義虛擬機(jī)模板
Registration information: name company
Computer name: Use the virtual machine name (important)
Product key: Didn’t need it because I’ve configured KMS
Password: Company default local administrator password, selected: Automatically login as the Administrator: 2
Timezone: GMT+0100 (Amsterdam)
Runonce: none
Network: Typical settings
Workgroup or Domain: selected to auto join the domain with domain administrator credentials + domain name (important)
Operation System Options: Selected: Generate New Security ID (SID)
Step2:VM模板設(shè)置
Hard disk: 40 GB with only OS configured with company standard policy
VMware tools: Latest, this must be installed for Specification Template and NIC
Network: VMXNET3 (needed VMware Tools for driver)
Step3:腳本保存(saved as: FileserverDeploy.ps1)
New-vm -vmhost esx04.vmpros.local -Name FS-SVR01 -Template WIN2008R2_Template -Datastore datastore2
-OSCustomizationspec WIN2008R2_Template
New-vm -vmhost esx04.vmpros.local -Name FS-SVR02 -Template WIN2008R2_Template -Datastore datastore2
-OSCustomizationspec WIN2008R2_Template
New-vm -vmhost esx04.vmpros.local -Name FS-SVR03 -Template WIN2008R2_Template -Datastore datastore2
-OSCustomizationspec WIN2008R2_Template
New-vm -vmhost esx04.vmpros.local -Name FS-SVR04 -Template WIN2008R2_Template -Datastore datastore2
-OSCustomizationspec WIN2008R2_Template
New-vm -vmhost esx04.vmpros.local -Name FS-SVR05 -Template WIN2008R2_Template -Datastore datastore2
-OSCustomizationspec WIN2008R2_Template
-vmhost = Target host;
-Name = Name of new VM;
-Template: From wich template you want to deploy the new VM;
-Datastore: Target datastore to place the new VM;
-OSCustomizationspec = Wich “prep” template you want to deploy the new VM;