次の方法で共有


[Windows 7, PowerShell] Windows Virtual PC を PowerShell で操作する

Windows 7 ?????? Windows Virtual PC ? COM ???????????????????

Virtual PC Guy’s WebLog:
Windows Virtual PC and PowerShell
https://blogs.msdn.com/virtual_pc_guy/archive/2009/07/14/windows-virtual-pc-and-powershell.aspx

Developing against Windows Virtual PC
https://blogs.msdn.com/virtual_pc_guy/archive/2009/07/13/developing-against-windows-virtual-pc.aspx

2????????????????COM ???????????????? MSDN Library ??????????(?????????????????????????????????)

MSDN Library: Windows Virtual PC
https://msdn.microsoft.com/en-us/library/dd796757(VS.85).aspx

????????????Windows Virtual PC ?????????????? Windows 7 ????????? COM ?????????????

PC C:\> $vpc = new-object –com VirtualPC.Application

$vpc ? IVMVirtualPC ?????????Windows Virtual PC ????????????????????????????????????????????????VirtualMachines ?????????????

PS C:\> $vm = $vpc.VirtualMachines

PS C:\> $vm | Format-Table Name, Memory, State -auto

Name Memory State
---- ------ -----
Virtual Windows 7 512 2
Virtual Windows Vista 512 1
Virtual Windows XP 256 2

?? (?????) ? IVMVirtualMachine ?????????????????????????????????State ???????????????????2 ??????1 ????? (????) ?????????????? VMVMState ??????????

?????????? “Virtual Windows XP” ?????????

PS C:\> $vm.Item(3).Startup()

PercentCompleted : 0
Description : ????? 'Virtual Windows XP' ???????
Result :
IsCancelable : False
ID : 2
IsComplete : False
Error : 0
ErrorDescription :

“Virtual Windows XP” ?3??????$vm.Item(3) ???????????????????$vpc.FindVirtualMachine("Virtual Windows XP") ?????????????????? Startup ??????????????????????????????????????????? Startup2 ??????????

?????????? OS ????????????????(???????????????)

PS C:\> $vm.Item(3).GuestOS

IsHostTimeSyncEnabled : True
HeartbeatPercentage : 100
IsHeartbeating : True
OSName : Windows® XP Professional Service Pack 3
IntegrationComponentsVersion : 14.0.7084.0
CanShutdown : True
TerminalServicesInitialized : True
OSMajorVersion : 5
OSMinorVersion : 1
OSBuildNumber : 2600
OSVersion : 5.1.2600
…(?)

????????????????CreateVirtualMachine ??????????????????????????????????????????????????????????? vmc ????????????

PS C:\> $vpc.CreateVirtualMachine("Demo VM", "e:\vm\Demo VM")

???????????????? VHD ??????????????????????????????

image

IVMVirtualPC ????????? CreateDynamicVirtualHardDisk ???????????? VHD ?????IVMVirtualMachine ????????? AddHardDiskConnection ??????????????????????

PS C:\> $vhd = "e:\vm\Demo VM\Demo VM.vhd"
PS C:\> $vpc.CreateDynamicVirtualHardDisk($vhd, 20000)

PercentCompleted : 0
Description : ???????? ???? Demo VM.vhd ????
Result :
IsCancelable : False
ID : 3
IsComplete : False
Error : 0
ErrorDescription :

PS C:\> $vpc.FindVirtualMachine("Demo VM").AddHardDiskConnection($vhd, 0, 0)

CreateDynamicVirtualHardDisk ?????????VHD ?????????AddHardDiskConnection ?????????VHD ???????????????????

?????????????

 image

??????Windows Virtual PC ?????????????????????????????????????