您可以使用 powershell 来“启动”新的 VM 实例吗

您可以使用 powershell 来“启动”新的 VM 实例吗

学习 powershell 并使用 Hyper-v 创建虚拟机。我想知道是否有方法或理想方法来安装/设置客户操作系统?

到目前为止,我得出的唯一结论是复制 .vhd/.vhdx 并将它们附加到新虚拟机。但是,我知道在 *nix 上这可能会导致整个网络设置出现问题,并且需要手动修复,但我认为这对 Windows 来说没问题?

编辑:是的,我知道 Hyper-V 的 cmdlet。但这不是我要问的。有没有办法在新创建的虚拟机上安装操作系统

答案1

http://technet.microsoft.com/en-us/magazine/jj933287.aspx这是创建虚拟机并从头开始安装操作系统的示例。

步骤包括创建虚拟机、配置虚拟机、添加源 ISO 和带有 unmattend.xml 的软盘,然后启动虚拟机

答案2

是的。PowerShell 可以对 Hyper-V 虚拟机执行很多操作。请从以下 CMDlet 中进行选择:

Add-VMDvdDrive
Add-VMFibreChannelHba
Add-VMHardDiskDrive
Add-VMMigrationNetwork
Add-VMNetworkAdapter
Add-VMNetworkAdapterAcl
Add-VMNetworkAdapterExtendedAcl
Add-VmNetworkAdapterRoutingDomainMapping
Add-VMRemoteFx3dVideoAdapter
Add-VMScsiController
Add-VMStoragePath
Add-VMSwitch
Add-VMSwitchExtensionPortFeature
Add-VMSwitchExtensionSwitchFeature
Checkpoint-VM
Compare-VM
Complete-VMFailover
Connect-VMNetworkAdapter
Connect-VMSan
Convert-VHD
Copy-VMFile
Debug-VM
Disable-VMEventing
Disable-VMIntegrationService
Disable-VMMigration
Disable-VMRemoteFXPhysicalVideoAdapter
Disable-VMResourceMetering
Disable-VMSwitchExtension
Disconnect-VMNetworkAdapter
Disconnect-VMSan
Dismount-VHD
Enable-VMEventing
Enable-VMIntegrationService
Enable-VMMigration
Enable-VMRemoteFXPhysicalVideoAdapter
Enable-VMReplication
Enable-VMResourceMetering
Enable-VMSwitchExtension
Export-VM
Export-VMSnapshot
Get-VHD
Get-VM
Get-VMBios
Get-VMComPort
Get-VMConnectAccess
Get-VMDvdDrive
Get-VMFibreChannelHba
Get-VMFirmware
Get-VMFloppyDiskDrive
Get-VMHardDiskDrive
Get-VMHost
Get-VMHostNumaNode
Get-VMHostNumaNodeStatus
Get-VMIdeController
Get-VMIntegrationService
Get-VMMemory
Get-VMMigrationNetwork
Get-VMNetworkAdapter
Get-VMNetworkAdapterAcl
Get-VMNetworkAdapterExtendedAcl
Get-VMNetworkAdapterFailoverConfiguration
Get-VmNetworkAdapterIsolation
Get-VMNetworkAdapterRoutingDomainMapping
Get-VMNetworkAdapterVlan
Get-VMProcessor
Get-VMRemoteFx3dVideoAdapter
Get-VMRemoteFXPhysicalVideoAdapter
Get-VMReplication
Get-VMReplicationAuthorizationEntry
Get-VMReplicationServer
Get-VMResourcePool
Get-VMSan
Get-VMScsiController
Get-VMSnapshot
Get-VMStoragePath
Get-VMSwitch
Get-VMSwitchExtension
Get-VMSwitchExtensionPortData
Get-VMSwitchExtensionPortFeature
Get-VMSwitchExtensionSwitchData
Get-VMSwitchExtensionSwitchFeature
Get-VMSystemSwitchExtension
Get-VMSystemSwitchExtensionPortFeature
Get-VMSystemSwitchExtensionSwitchFeature
Grant-VMConnectAccess
Import-VM
Import-VMInitialReplication
Measure-VM
Measure-VMReplication
Measure-VMResourcePool
Merge-VHD
Mount-VHD
Move-VM
Move-VMStorage
New-VFD
New-VHD
New-VM
New-VMReplicationAuthorizationEntry
New-VMResourcePool
New-VMSan
New-VMSwitch
Optimize-VHD
Remove-VM
Remove-VMDvdDrive
Remove-VMFibreChannelHba
Remove-VMHardDiskDrive
Remove-VMMigrationNetwork
Remove-VMNetworkAdapter
Remove-VMNetworkAdapterAcl
Remove-VMNetworkAdapterExtendedAcl
Remove-VMNetworkAdapterRoutingDomainMapping
Remove-VMRemoteFx3dVideoAdapter
Remove-VMReplication
Remove-VMReplicationAuthorizationEntry
Remove-VMResourcePool
Remove-VMSan
Remove-VMSavedState
Remove-VMScsiController
Remove-VMSnapshot
Remove-VMStoragePath
Remove-VMSwitch
Remove-VMSwitchExtensionPortFeature
Remove-VMSwitchExtensionSwitchFeature
Rename-VM
Rename-VMNetworkAdapter
Rename-VMResourcePool
Rename-VMSan
Rename-VMSnapshot
Rename-VMSwitch
Repair-VM
Reset-VMReplicationStatistics
Reset-VMResourceMetering
Resize-VHD
Restart-VM
Restore-VMSnapshot
Resume-VM
Resume-VMReplication
Revoke-VMConnectAccess
Save-VM
Set-VHD
Set-VM
Set-VMBios
Set-VMComPort
Set-VMDvdDrive
Set-VMFibreChannelHba
Set-VMFirmware
Set-VMFloppyDiskDrive
Set-VMHardDiskDrive
Set-VMHost
Set-VMMemory
Set-VMMigrationNetwork
Set-VMNetworkAdapter
Set-VMNetworkAdapterFailoverConfiguration
Set-VmNetworkAdapterIsolation
Set-VmNetworkAdapterRoutingDomainMapping
Set-VMNetworkAdapterVlan
Set-VMProcessor
Set-VMRemoteFx3dVideoAdapter
Set-VMReplication
Set-VMReplicationAuthorizationEntry
Set-VMReplicationServer
Set-VMResourcePool
Set-VMSan
Set-VMSwitch
Set-VMSwitchExtensionPortFeature
Set-VMSwitchExtensionSwitchFeature
Start-VM
Start-VMFailover
Start-VMInitialReplication
Stop-VM
Stop-VMFailover
Stop-VMInitialReplication
Stop-VMReplication
Suspend-VM
Suspend-VMReplication
Test-VHD
Test-VMNetworkAdapter
Test-VMReplicationConnection

答案3

一般来说,安装操作系统不是虚拟机管理程序的工作。使用 powershell 配置虚拟机,然后您将启动构建过程,该过程也可以编写脚本。在我开始使用 pxe 启动 MDT 映像之前,我有要安装的无人值守 iso 文件。系统启动后,它会运行自引导安装。我猜你会想要类似这样的内容。

答案4

除了使用无人值守文件从媒体安装外,完全可以离线配置最新版本的 Windows,而且速度可能更快。您可以使用 Hyper-V PowerShell cmdlet 创建 VHD。然后在其中安装 Windows 映像。然后,将 VHD 连接到 VM 并启动它。

也许最简单的方法是使用 WIM2VHD 脚本:

http://www.bing.com/search?q=Convert-WindowsImage.ps1%20%E2%80%94%20WIM2VHD%20for%20Windows%208%20and%20Windows%208.1&qs=n&form=QBRE&pq=convert-windowsimage.ps1%20%E2%80%94%20wim2vhd%20for%20windows%208%20and%20windows%208.1&sc=0-7&sp=-1&sk=&cvid=cd83b480e637456090505eefa3fbc5f2

如果您想深入了解,上述脚本是根据 OPK/AIK/MDT 技术中的原语构建的:

http://www.bing.com/search?q=Deploy%20Windows%208.1%20with%20the%20Microsoft%20Deployment%20Toolkit&qs=n&form=QBRE&pq=deploy%20windows%208.1%20with%20the%20microsoft%20deployment%20toolkit&sc=0-0&sp=-1&sk=&cvid=e821766decfe449381a60f13de482664

相关内容