基于VMware vSphere 5.0的服务器虚拟化实践(8)

本文介绍如何使用PowerCLI脚本快速批量部署虚拟机。通过自定义虚拟机模板和配置脚本参数,可以在短时间内轻松创建多台一致的虚拟机,极大地提高了工作效率。

【VMware vSphere 5.0服务器虚拟化实践系列(8) :使用脚本PowerCLI部署虚拟机】

在上一篇博文中我使用克隆及模板的方式来部署虚拟机,但不管是从模板部署还是对虚拟机进行克隆,都只能一对一,不能一对多。如果需要部署N台虚拟机的话,两种方法都不是那么有效。那么是否有更快捷的方法呢?当然有,用脚本PowerCLI。接下来我就用PowerCLI来同时部署多台虚拟机。

Step1:自定义虚拟机模板

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模板设置

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值