PowerShell: 批量导入Hyper-V虚拟机
作者: lesca
分类: Hyper-V, Tutorials
发布时间: 2017-07-24 13:19
ė浏览 2,893 次
6Comments Off on PowerShell: 批量导入Hyper-V虚拟机
前提条件
本文所介绍的方法要求以下目录保持原有的相对关系、目录结构及所在盘符不能改变。
- Virtual Machines
- Snapshots
- VHD文件夹(可以是多个)
导入方法
path = 'D:\Hyper-V\Virtual Machines' # Get the VM configuration files Get-ChildItempath -Recurse -Filter *.vmcx # Check VM import / register Get-ChildItem path -Recurse -Filter *.vmcx | %{Compare-VM_.FullName -Register} | %{Write-Host "(_.VM.VMName) - (_.VM.Id) : (_.Incompatibilities.message)"} # Import VM (after check) Get-ChildItem path -Recurse -Filter *.vmcx | %{Import-VM_.FullName -Register}
附:vmcx配置文件查看脚本
path = 'G:\DriveD\Hyper-V\Virtual Machines' # Get the VM configuration filesVMProfiles = Get-ChildItem path -Recurse -Filter *.vmcx # Get specific VM configurationVMResult = VMProfiles | % { (Compare-VM -Copy_.Fullname).VM } | ? {_.VMName -like "RDS*"} # Get Useful ConfigurationVMResult[0] | select VMName,VMId,ParentCheckpointId $VMResult | select VMName,VMId,ParentCheckpointId
Copyright
本文出自 Lesca 技术宅,转载时请注明出处及相应链接。
本文永久链接: https://lesca.me/archives/bulk-import-hyperv-vms-using-powershell.html