-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path33 School_Child_VM.ps1
More file actions
29 lines (23 loc) · 1.11 KB
/
Copy path33 School_Child_VM.ps1
File metadata and controls
29 lines (23 loc) · 1.11 KB
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
#Creater: Dominic Vienneau
#Created: Saturday April, 9 2022
#DESCRIPTION: Creates a VHDX with a differencing disk followed by Greating a VM for that Disk
$OSPick = Read-Host "What would you like?`n1 = Windows 10`n2 = Windows Server 2019`n"
If($OSPick -eq 2) { $ParentPath = 'S:\Parent VHD\Server 2019\Server 2019 parent Disk.vhdx'}
if($OSPick -eq 1) { $ParentPath = 'S:\Parent VHD\Windows 10\Windows 10 parent.vhdx'}
$VMLocation = 'S:\Scratch'
$VSwitch = 'External Switch'
$RAM = 4GB
$Cores = 2
$VMName = Read-Host "Name your Virtual Machine"
Set-ItemProperty -Path $ParentPath -Name IsReadOnly -Value $true
$path = 'S:\Scratch'
#Create the Differencing Disk VHD
$VHD = New-VHD -Path ($path.FullName + "\" + $vmname + ".vhdx") -ParentPath $ParentPath -Differencing
#Create the Virtual Machine with the Differencing Disk Hard Drive
New-VM -Name $VMName -Path $VMLocation -VHDPath $VHD.Path -BootDevice VHD -Generation 2 -SwitchName $vSwitch | `
Set-VMMemory -DynamicMemoryEnabled $true `
-MaximumBytes $RAM -MinimumBytes 512MB -StartupBytes 1GB `
Set-VMProcessor -VMname $VMname -Count $Cores
#Start the VM
Start-vm $VMName
#End