-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnew-gdlabvm.psm1
65 lines (48 loc) · 1.36 KB
/
new-gdlabvm.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function new-gdlabvm
{
[CmdletBinding()]
[Alias()]
[OutputType()]
Param
(
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]$VMNames,
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$HDDName,
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$CPUcores,
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$Memory,
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
$outputpath
)
Begin
{
Remove-Item $outputpath"\deployoutput.txt"
}
Process
{
foreach ($VMName in $VMNames){
New-VM -Name $VMName -SwitchName "LAN" -MemoryStartupBytes $Memory -VHDPath $HDDName -Generation 2
Set-VM -Name $VMName -ProcessorCount $CPUCores -StaticMemory:$true
Set-VMNetworkAdapter -VMName $VMName -MacAddressSpoofing On -DhcpGuard On -RouterGuard On
Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true
Start-VM -Name $VMName
}
}
End
{
get-vm | where name -Contains $VMNames[0] > $outputpath"\deployoutput.txt"
}
}