Last active 1440821824

Set up test vm in hyper-v

Steven Smith revised this gist 1426306627. Go to revision

1 file changed, 20 insertions

testvm.ps1(file created)

@@ -0,0 +1,20 @@
1 + function Connect-VM {
2 + param(
3 + [Parameter(ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true, Position=1)]
4 + [Microsoft.HyperV.PowerShell.VirtualMachine[]]$VM,
5 + [switch] $PassThru
6 + )
7 + PROCESS {
8 + foreach ($VMobject in $VM) {
9 + vmconnect localhost ($VMobject.name)
10 + }
11 + if($PassThru) {$_}
12 + }
13 + }
14 +
15 + new-vmswitch -name Int
16 + new-vm -name 'testvm' -MemoryStartupBytes 1GB -SwitchName Int
17 + add-vmdvddrive testvm -path "t:\wineval\8.1 Eval.iso"
18 + new-vhd -dynamic c:\testvm.vhdx -sizebytes 20GB
19 + Add-VMHardDiskDrive testvm -path c:\testvm.vhdx
20 + get-vm -name testvm | start-vm -passthru | connect-vm
Newer Older