如何解决Powershell从批量创建Vms
我想从Bulk(CVS)创建一些VMS 使用此选项(我使用此脚本创建虚拟机,并且我想输入这些内容(例如批量输入VM名称,磁盘路径和RAM等))
New-VM -Name "IL-DC1" -MemoryStartupBytes 2GB -BootDevice VHD -NewVHDPath "S:\Virtual LAB\Hyper-V\Virtual_Machines\IL-DC1\IL-DC1.VHDX" -Path D:\Hyper-V\VMS -NewVHDSizeBytes 30GB -Generation 2
Set-VM "IL-DC1" -ProcessorCount 2
Set-VMMemory "IL-DC1" -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 2GB -MaximumBytes 4GB -Priority 80 -Buffer 50
Add-VMDvdDrive -VMName "IL-DC1" -Path "S:\OS\Windows Server\Server2016.ISO"
Connect-VMNetworkAdapter -VMName "IL-DC1" -SwitchName IL-Lan
我想大量包装以便可以更改的东西
- VM名称
- MemoryStartupBytes
- NewVHDPath
- (虚拟机的)路径
- NewVHDSizeBytes
- ProcessorCount
- MinimumBytes
- StartupBytes
- MaximumBytes
优先级80和缓冲区50 ---->此值不变
- VMDvdDrive
- SwitchName
还有一个脚本,它将像我编写的脚本一样从CVS获取所有这些数据并创建此vms。
我知道互联网上有数十亿名导游,但在这里我总是找到最好的解决方案。 谢谢你!
解决方法
这是很平常的事情,需要大量的预构建脚本来根据您的用例进行调整和调整。
Create-VM.ps1 PowerShell script to create Hyper-V Virtual Machines in bulk
该脚本已被弃用。它已被重写并成为一部分 可用的SBTools PS模块
此处。http://gallery.technet.microsoft.com/scriptcenter/SBTools-module-adds-38992422NAME
用于创建Hyper-V虚拟机的New-SBVM概要功能
Create Multiple Hyper-V Virtual Machines via PowerShell
此快速又肮脏的PowerShell脚本可在 Windows Server 2012 Hyper-V主机。如果您需要,这是完美的 在实验室或演示环境中创建很多虚拟机。
甚至可以通过Microsfot powershellgallery.com预先构建模块来构建批量VMlab
Find-Module -Name '*lab*' | Format-Table -AutoSize
# Results
<#
Find-Module -Name '*lab*' | Format-Table -AutoSize
Version Name Repository Description
------- ---- ---------- -----------
...
5.22.0 AutomatedLab PSGallery The module creates a Hyper-V visual lab automatically as defined in the XML files.
2.0.208 AutomatedLab.Common PSGallery The module collects all helper functions used in but not limited to AutomatedLab
...
1.0.5.105 LabBuilder PSGallery Builds Hyper-V Windows multi-machine/Active Directory labs using XML configuration files and DSC Resources.
...
#>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。