Skip to content

Instantly share code, notes, and snippets.

@mgreenegit
Last active August 29, 2015 14:27
Show Gist options
  • Save mgreenegit/c665cd45e93992338876 to your computer and use it in GitHub Desktop.
Save mgreenegit/c665cd45e93992338876 to your computer and use it in GitHub Desktop.
Hyper-V Configuration
# This script is intended to configure Hyper-V on a Windows 10 machine where virtual disks are already present.
Configuration testbox
{
Import-DscResource -module xHyper-V, xDismFeature
Node localhost
{
xDismFeature HyperV
{
Ensure = 'Present'
Name = 'Microsoft-Hyper-V-All'
}
# The next two nodes might not be needed.
xDismFeature HyperVPSModule
{
Ensure = 'Present'
Name = 'Microsoft-Hyper-V-Management-PowerShell'
DependsOn = '[xDismFeature]HyperV'
}
xDismFeature VMConnect
{
Ensure = 'Present'
Name = 'Microsoft-Hyper-V-Management-Clients'
DependsOn = '[xDismFeature]HyperV'
}
xVMSwitch ExternalSwitch
{
Ensure = 'Present'
Name = 'External'
Type = 'External'
NetAdapterName = 'Wi-Fi'
AllowManagementOS = $False
DependsOn = '[xDismFeature]HyperV'
}
# If disks needed to be created, that could be inserted here. See examples folder in xHyper-V module.
xVMHyperV Nano
{
Ensure = 'Present'
Name = 'Nano'
VhdPath = 'C:\VM\nano\nano.vhdx'
SwitchName = 'External'
Path = 'C:\VM\nano\'
Generation = 2
StartupMemory = 767557632
ProcessorCount = 1
DependsOn = '[xDismFeature]HyperV','[xVMSwitch]ExternalSwitch'
}
xVMHyperV Server2012R2
{
Ensure = 'Present'
Name = 'Server2012R2'
VhdPath = 'C:\VM\server2012r2\server2012r2.vhdx'
SwitchName = 'External'
Path = 'C:\VM\server2012r2\'
Generation = 2
StartupMemory = 767557632
ProcessorCount = 1
DependsOn = '[xDismFeature]HyperV','[xVMSwitch]ExternalSwitch'
}
xVMHyperV Server2016
{
Ensure = 'Present'
Name = 'Server2016'
VhdPath = 'C:\VM\server2016\server2016.vhdx'
SwitchName = 'External'
Path = 'C:\VM\server2016\'
Generation = 2
StartupMemory = 767557632
ProcessorCount = 1
DependsOn = '[xDismFeature]HyperV','[xVMSwitch]ExternalSwitch'
}
}
}
testbox -out c:\dsc\testbox\
Start-DscConfiguration -wait -verbose -path c:\dsc\testbox\ -force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment