зеркало из https://github.com/microsoft/MSLab.git
Коммит
f4a1cba0ac
|
@ -192,6 +192,18 @@ function Get-WindowsBuildNumber {
|
|||
|
||||
#endregion
|
||||
|
||||
#region Installing PSDesiredStateConfiguration from the PowerShell gallery
|
||||
|
||||
# See https://learn.microsoft.com/en-us/powershell/dsc/overview?view=dsc-2.0 for details
|
||||
# on the breaking change that requires this module to be installed.
|
||||
WriteInfoHighlighted "Testing if PSDesiredStateConfiguration is present"
|
||||
if (!(Get-Module -ListAvailable -Name PSDesiredStateConfiguration)) {
|
||||
WriteInfo "`t Module PSDesiredStateConfiguration not found... Downloading"
|
||||
Install-Module -Name PSDesiredStateConfiguration -Repository PSGallery -MaximumVersion 2.99
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Downloading required Posh Modules
|
||||
# Downloading modules into Temp folder if needed.
|
||||
|
||||
|
|
|
@ -424,7 +424,11 @@ If (-not $isAdmin) {
|
|||
WriteInfo "`t Creating OS VHD"
|
||||
New-VHD -ParentPath $serverparent.fullname -Path $vhdpath
|
||||
|
||||
$VMTemp = New-VM -Path "$LabFolder\VMs" -Name $VMname -Generation 2 -MemoryStartupBytes $VMConfig.MemoryStartupBytes -SwitchName $SwitchName -VHDPath $vhdPath
|
||||
if ($VMConfig.VMVersion){
|
||||
$VMTemp = New-VM -Path "$LabFolder\VMs" -Name $VMname -Generation 2 -MemoryStartupBytes $VMConfig.MemoryStartupBytes -SwitchName $SwitchName -VHDPath $vhdPath -Version $VMConfig.VMVersion
|
||||
}else{
|
||||
$VMTemp = New-VM -Path "$LabFolder\VMs" -Name $VMname -Generation 2 -MemoryStartupBytes $VMConfig.MemoryStartupBytes -SwitchName $SwitchName -VHDPath $vhdPath
|
||||
}
|
||||
|
||||
#Set dynamic memory
|
||||
if ($VMConfig.StaticMemory -eq $false){
|
||||
|
@ -547,14 +551,22 @@ If (-not $isAdmin) {
|
|||
New-VHD -ParentPath $serverparent.fullname -Path $vhdpath
|
||||
|
||||
#Get VM Version
|
||||
[System.Version]$VMVersion=(Get-WindowsImage -ImagePath $VHDPath -Index 1).Version
|
||||
WriteInfo "`t VM Version is $($VMVersion.Build).$($VMVersion.Revision)"
|
||||
[System.Version]$BuildVersion=(Get-WindowsImage -ImagePath $VHDPath -Index 1).Version
|
||||
WriteInfo "`t VM Version is $($BuildVersion.Build).$($BuildVersion.Revision)"
|
||||
|
||||
WriteInfo "`t Creating VM"
|
||||
if ($VMConfig.Generation -eq 1){
|
||||
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 1
|
||||
if ($VMConfig.VMVersion){
|
||||
if ($VMConfig.Generation -eq 1){
|
||||
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 1 -Version $VMConfig.VMVersion
|
||||
}else{
|
||||
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 2 -Version $VMConfig.VMVersion
|
||||
}
|
||||
}else{
|
||||
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 2
|
||||
if ($VMConfig.Generation -eq 1){
|
||||
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 1
|
||||
}else{
|
||||
$VMTemp=New-VM -Name $VMname -VHDPath $vhdpath -MemoryStartupBytes $VMConfig.MemoryStartupBytes -path "$LabFolder\VMs" -SwitchName $SwitchName -Generation 2
|
||||
}
|
||||
}
|
||||
$VMTemp | Set-VMMemory -DynamicMemoryEnabled $true
|
||||
$VMTemp | Get-VMNetworkAdapter | Rename-VMNetworkAdapter -NewName Management1
|
||||
|
@ -742,7 +754,7 @@ If (-not $isAdmin) {
|
|||
WriteInfo "`t`t No sync commands requested"
|
||||
}
|
||||
|
||||
if ($VMVersion.Build -ge 17763){
|
||||
if ($BuildVersion.Build -ge 17763){
|
||||
$oeminformation=@"
|
||||
<OEMInformation>
|
||||
<SupportProvider>MSLab</SupportProvider>
|
||||
|
@ -1162,13 +1174,31 @@ If (-not $isAdmin) {
|
|||
|
||||
WriteInfo "`t Starting IP for AdditionalNetworks is $global:IP"
|
||||
|
||||
#Create Mount nd VMs directories
|
||||
#Create Mount and VMs directories
|
||||
WriteInfoHighlighted "Creating Mountdir"
|
||||
New-Item $mountdir -ItemType Directory -Force
|
||||
|
||||
WriteInfoHighlighted "Creating VMs dir"
|
||||
New-Item "$PSScriptRoot\LAB\VMs" -ItemType Directory -Force
|
||||
|
||||
#unmount&cleanup mounted images
|
||||
WriteInfoHighlighted "Unmounting images from previous run"
|
||||
$MountedImages=Get-WindowsImage -Mounted | Where-Object MountStatus -ne "Invalid"
|
||||
if ($MountedImages){
|
||||
WriteInfo "`t Mounted images found, Dismounting, discarting"
|
||||
$MountedImages | Dismount-WindowsImage -Discard -ErrorAction Ignore
|
||||
}else{
|
||||
WriteInfo "`t No mounted images found"
|
||||
}
|
||||
#cleanup corrupted
|
||||
$InvalidImages=Get-WindowsImage -Mounted | Where-Object MountStatus -eq "Invalid"
|
||||
if ($InvalidImages){
|
||||
WriteInfo "`t Invalid mountpoints found, clearing"
|
||||
Clear-WindowsCorruptMountPoint
|
||||
}else{
|
||||
WriteInfo "`t No invalid mountpoints found"
|
||||
}
|
||||
|
||||
#get path for Tools disk
|
||||
WriteInfoHighlighted "Looking for Tools Parent Disks"
|
||||
$toolsparent=Get-ChildItem "$PSScriptRoot\ParentDisks" -Recurse | Where-Object name -eq tools.vhdx
|
||||
|
@ -1493,9 +1523,9 @@ If (-not $isAdmin) {
|
|||
if(-not $VMConfig.configuration) {
|
||||
$VMConfig.configuration = "Simple"
|
||||
}
|
||||
# Ensure that MemoryStartupBytes is set to use 512MB as default
|
||||
# Ensure that MemoryStartupBytes is set to use 1GB as default
|
||||
if(-not $VMConfig.MemoryStartupBytes) {
|
||||
$VMConfig.MemoryStartupBytes = 512MB
|
||||
$VMConfig.MemoryStartupBytes = 1GB
|
||||
}
|
||||
|
||||
#create VM with Shared configuration
|
||||
|
|
|
@ -4,9 +4,9 @@ $LabConfig=@{AllowedVLANs="1-10,711-719" ; DomainAdminName='LabAdmin'; AdminPass
|
|||
# Windows Server 2022
|
||||
1..4 | ForEach-Object {$LABConfig.VMs += @{ VMName = "$S2D$_" ; Configuration = 'S2D' ; ParentVHD = 'Win2022Core_G2.vhdx'; SSDNumber = 0; SSDSize=800GB ; HDDNumber = 12; HDDSize= 4TB ; MemoryStartupBytes= 512MB }}
|
||||
# Or Azure Stack HCI 23H2 (non-domain joined) https://github.com/DellGEOS/AzureStackHOLs/tree/main/lab-guides/01a-DeployAzureStackHCICluster-CloudBasedDeployment
|
||||
#1..2 | ForEach-Object {$LABConfig.VMs += @{ VMName = "ASNode$_" ; Configuration = 'S2D' ; ParentVHD = 'AzSHCI23H2_G2.vhdx' ; HDDNumber = 4 ; HDDSize= 2TB ; MemoryStartupBytes= 20GB; VMProcessorCount=16 ; vTPM=$true ; Unattend="NoDjoin" ; NestedVirt=$true }}
|
||||
#1..2 | ForEach-Object {$LABConfig.VMs += @{ VMName = "ASNode$_" ; Configuration = 'S2D' ; ParentVHD = 'AzSHCI23H2_G2.vhdx' ; HDDNumber = 4 ; HDDSize= 2TB ; MemoryStartupBytes= 24GB; VMProcessorCount=16 ; vTPM=$true ; Unattend="NoDjoin" ; NestedVirt=$true }}
|
||||
# Or Windows Server 2025 https://github.com/DellGEOS/AzureStackHOLs/tree/main/lab-guides/03-TestingWindowsServerInsider
|
||||
#1..2 | ForEach-Object {$LABConfig.VMs += @{ VMName="S2D$_" ; Configuration='S2D' ; ParentVHD='WinSrvInsiderCore_26063.vhdx' ; HDDNumber=4 ; HDDSize=2TB ; MemoryStartupBytes=1GB; VMProcessorCount=4 ; vTPM=$true}}
|
||||
#1..2 | ForEach-Object {$LABConfig.VMs += @{ VMName="S2D$_" ; Configuration='S2D' ; ParentVHD='Win2025Core_G2.vhdx' ; HDDNumber=4 ; HDDSize=2TB ; MemoryStartupBytes=1GB; VMProcessorCount=4 ; vTPM=$true}}
|
||||
|
||||
### HELP ###
|
||||
|
||||
|
@ -340,6 +340,11 @@ $LabConfig=@{AllowedVLANs="1-10,711-719" ; DomainAdminName='LabAdmin'; AdminPass
|
|||
#DisableTimeIC (Optional)
|
||||
Example DisableTimeIC=$true
|
||||
if $true, time Hyper-V Time Synchronization Integration Service (VMICTimeProvider) will be disabled
|
||||
|
||||
#VMVersion (Optional)
|
||||
Example VMVersion="10.0"
|
||||
default versions - Windows Server 2022 = 10.0, Widnows Server 2025 = 12.0
|
||||
https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/deploy/Upgrade-virtual-machine-version-in-Hyper-V-on-Windows-or-Windows-Server
|
||||
#>
|
||||
#endregion
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче