Created
November 23, 2013 17:02
-
-
Save altrive/7617167 to your computer and use it in GitHub Desktop.
Sample config to create Hyper-V VM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#global variable | |
$global:ctx = @{ | |
VmName = "Windows 8.1" | |
Operation = "" | |
Session = $null | |
ComputerName = "TestPC" | |
DomainJoin =@{ | |
Name = "TEST.local" | |
Credential = Get-SavedCredential -Id DomainAdmin | |
} | |
NetworkShare = @{ | |
Path = "\\172.16.0.1\Shared" | |
Credential = Get-SavedCredential -Id FileShare | |
} | |
ImagePath= @{ | |
DotNet35 = "\\172.16.0.1\Shared\Images\Windows8.1\WinSxS" | |
VisualStudio = "\\172.16.0.1\Shared\Images\VisualStudio2012" | |
VisualStudioUpdate = "\\172.16.0.1\Shared\Images\VS2012_Update3" | |
ManagementStudio = "\\172.16.0.1\Shared\Images\SQLServer2012_SP1" | |
} | |
} | |
$vmTemplates = @{ | |
VmName = $ctx.VmName | |
VmLocation = (Get-VMHost).VirtualMachinePath | |
CpuConfig = @{ | |
Count = 4 | |
#EnableCompatibility = $false | |
} | |
SystemDiskConfig = @{ | |
ParentPath = Join-Path (Get-VMHost).VirtualHardDiskPath "Windows8.1_Enterprise.vhdx" -Resolve | |
Differencing = $true | |
SizeBytes = 128GB | |
BlockSizeBytes = 2MB | |
} | |
DataDiskConfig = [ordered] @{ | |
DriveD = @{ | |
SizeBytes = 128GB | |
BlockSizeBytes = 256MB | |
LogicalSectorSizeBytes = 4KB | |
PhysicalSectorSizeBytes = 4KB | |
Dynamic = $true | |
} | |
DriveE = @{ | |
SizeBytes = 128GB | |
BlockSizeBytes = 256MB | |
LogicalSectorSizeBytes = 4KB | |
PhysicalSectorSizeBytes = 4KB | |
Dynamic = $true | |
} | |
} | |
MemoryConfig = @{ | |
StartupBytes = 4GB | |
DynamicMemoryEnabled = $true | |
MaximumBytes = 8GB | |
MinimumBytes = 2GB | |
} | |
NetworkConfig = [ordered] @{ | |
Lan1 = @{ SwitchName = "内部LAN" } | |
} | |
StartupActionConfig = @{ | |
AutomaticStartAction = "StartIfRunning" | |
AutomaticStartDelay = 30 | |
AutomaticStopAction = "ShutDown" | |
} | |
OtherConfig = @{ | |
VmGeneration = 2 #Gen2 VM Require Windows8.1/2012 R2 Hyper-V | |
DisableTimeSync = $true | |
EnableGuestService = $true #Require Windows8.1/2012 R2 Hyper-V | |
EnableResourceMetering = $true | |
EnableDvdDrive = $true #Gen2 VM contains no DVD drive by default | |
SuppressPxeBoot = $true #Gen2 VM primary boot order is PXE boot.and take times to startup first boot. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This looks much tidier than my previous attempts, chance of sharing the code which would use this powershell config to build the virtual machine ?