-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New-LabVM #40
New-LabVM #40
Conversation
Adds localisation in NewLabVM
Conflicts: Src/LabVMDefaults.ps1
@csandfeld - here's the 'quick VM' functionality. Would you mind have a look through? I've called the new cmdlet New-LabVM, but I'm not sure if that confuses things (I did originally name it New-LabQuickVM)? |
Looks promissing, but at first try I run into a couple of errors: D:\SourceControl\Lab [Issue29]> Get-LabVMDefault
StartupMemory : 2147483648
MinimumMemory : 536870912
MaximumMemory : 1099511627776
ProcessorCount : 2
SwitchName : External
Media : 2012R2_x64_Standard_EN_Eval
TimeZone : GMT Standard Time
UILanguage : en-US
SystemLocale : da-DK
InputLocale : 0406:00000406
UserLocale : da-DK
Password :
RegisteredOwner : DGS
RegisteredOrganization : DGS
ClientCertificatePath : %ALLUSERSPROFILE%\VirtualEngineLab\Certificates\LabClient.pfx
RootCertificatePath : %ALLUSERSPROFILE%\VirtualEngineLab\Certificates\LabRoot.cer
BootDelay : 0
D:\SourceControl\Lab [Issue29]> New-LabVM -Name WIN10CLIENT -Id WIN10_x64_Enterprise_EN_Eval
New-VM : Sequence contains more than one element
At D:\SourceControl\Lab\DSCResources\xHyper-V\DSCResources\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:291 char:21
+ $null = New-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.HyperV.PowerShell.Commands.NewVM
Set-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\DSCResources\xHyper-V\DSCResources\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:312 char:21
+ $null = Set-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Set-VM], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.SetVM
WARNING: [11:15:54] Cannot locate node 'D:\TestLab\Configurations\WIN10CLIENT.mof' file. No DSC configuration will be
applied. Ensure the DSC configuration has been run successfully.
Checkpoint-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\Src\LabVM.ps1:269 char:13
+ Checkpoint-VM -Name $Name -SnapshotName $snapshotName;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Checkpoint-VM], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.CheckpointVM
Get-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\Src\LabVM.ps1:281 char:36
+ Write-Output -InputObject (Get-VM -Name $Name);
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (WIN10CLIENT:String) [Get-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVM
D:\SourceControl\Lab [Issue29]> |
On a side note - I'm wondering if it would maybe make more sense to rename the 'Id' parameter to 'MediaId' or something along those lines - just to give an indication of what it is used for. |
With regards to the function name ... hmm ... don't know ... I feel that New-LabVM would be the right name, but can see how that might be confusing. New-LabQuickVM might be a more explanatory naming, but I find it kind of awkward. |
Same as before but with verbose output: D:\SourceControl\Lab [Issue29]> New-LabVM -Name WIN10CLIENT -Id WIN10_x64_Enterprise_EN_Eval -Verbose
VERBOSE: [12:08:32] Creating quick VM 'WIN10CLIENT' using media ''.
VERBOSE: [12:08:32] Setting Virtual Switch configuration 'External'.
VERBOSE: [12:08:32] Checking DSC Resource 'xHyper-V\MSFT_xVMSwitch'.
VERBOSE: [12:08:32] Invoking command 'Test-VMSwitchTargetResource'.
VERBOSE: [12:08:33] Skipping command 'Set-VMSwitchTargetResource'.
VERBOSE: [12:08:33] (Re)setting VHDX configuration 'WIN10_x64_Enterprise_EN_Eval'.
VERBOSE: [12:08:33] Checking DSC Resource 'xHyper-V\MSFT_xVHD'.
VERBOSE: [12:08:33] Invoking command 'Test-VHDTargetResource'.
VERBOSE: [12:08:33] Testing 'Test-VHDTargetResource' failed.
VERBOSE: [12:08:33] Invoking command 'Set-VHDTargetResource'.
VERBOSE: [12:08:34] Checking DSC Resource 'xHyper-V\MSFT_xVHD'.
VERBOSE: [12:08:34] Invoking command 'Test-VHDTargetResource'.
VERBOSE: [12:08:34] Testing 'Test-VHDTargetResource' failed.
VERBOSE: [12:08:34] Invoking command 'Set-VHDTargetResource'.
VERBOSE: [12:08:35] Setting VM configuration 'WIN10CLIENT'.
VERBOSE: [12:08:35] Checking DSC Resource 'xHyper-V\MSFT_xVMHyperV'.
VERBOSE: [12:08:35] Invoking command 'Test-VMTargetResource'.
VERBOSE: [12:08:35] Testing 'Test-VMTargetResource' failed.
VERBOSE: [12:08:35] Invoking command 'Set-VMTargetResource'.
New-VM : Sequence contains more than one element
At D:\SourceControl\Lab\DSCResources\xHyper-V\DSCResources\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:291 char:21
+ $null = New-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.HyperV.PowerShell.Commands.NewVM
Set-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\DSCResources\xHyper-V\DSCResources\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:312 char:21
+ $null = Set-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Set-VM], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.SetVM
VERBOSE: [12:08:36] Adding VM customizations.
VERBOSE: [12:08:36] Mounting disk image 'D:\TestLab\VMVirtualHardDisks\WIN10CLIENT.vhdx'.
VERBOSE: [12:08:37] Adding DSC resource modules to 'J:\Program Files\WindowsPowershell\Modules'.
VERBOSE: [12:08:37] Adding DSC resource 'xActiveDirectory' (v2.6.0.0).
VERBOSE: [12:08:37] Adding DSC resource 'xComputerManagement' (v1.3.0).
VERBOSE: [12:08:37] Adding DSC resource 'xDhcpServer' (v1.2).
VERBOSE: [12:08:37] Adding DSC resource 'xDnsServer' (v1.1).
VERBOSE: [12:08:37] Adding DSC resource 'xNetworking' (v2.3.0.0).
VERBOSE: [12:08:37] Adding DSC resource 'xSmbShare' (v1.1.0.0).
VERBOSE: [12:08:37] Setting local administrator password to 'Passw0rd'.
VERBOSE: [12:08:37] Adding Unattend file 'J:\Windows\System32\Sysprep\Unattend.xml'.
VERBOSE: [12:08:37] Adding BootStrap.ps1 file to 'J:\BootStrap'.
VERBOSE: [12:08:37] Creating directory 'J:\BootStrap'.
VERBOSE: [12:08:37] Adding SetupComplete.cmd to 'J:\Windows\Setup\Scripts'.
VERBOSE: [12:08:37] Creating directory 'J:\Windows\Setup\Scripts'.
VERBOSE: [12:08:37] Adding DSC file 'J:\BootStrap\localhost.mof'.
WARNING: [12:08:37] Cannot locate node 'D:\TestLab\Configurations\WIN10CLIENT.mof' file. No DSC configuration will be
applied. Ensure the DSC configuration has been run successfully.
VERBOSE: [12:08:37] Adding Client certificate 'J:\BootStrap\LabClient.pfx'.
VERBOSE: [12:08:37] Adding Root certificate 'J:\BootStrap\LabRoot.cer'.
VERBOSE: [12:08:37] Dismounting disk image 'D:\TestLab\VMVirtualHardDisks\WIN10CLIENT.vhdx'.
VERBOSE: [12:08:37] Creating baseline snapshot 'VirtualEngineLab Baseline Snapshot'.
Checkpoint-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\Src\LabVM.ps1:269 char:13
+ Checkpoint-VM -Name $Name -SnapshotName $snapshotName;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Checkpoint-VM], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.CheckpointVM
Get-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\Src\LabVM.ps1:281 char:36
+ Write-Output -InputObject (Get-VM -Name $Name);
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (WIN10CLIENT:String) [Get-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVM
D:\SourceControl\Lab [Issue29]> |
It looks like the media (Id) dynamic parameter is not being passed through (looking at the verbose output)?
|
Renames the media -Id parameter to -MediaId
@csandfeld I can't recreate this. However, it looks like something is not being passed into the xVMHyperV resource. I've added some additional/temporary debugging information to show what is being passed to the nested Hyper-V DSC resource. Would you mind rerunning with the latest commit and let me know what's displayed on screen? Note: the -Id parameter has been renamed to -MediaId. Here's an example of the output on my machine: [18] C:\..\Dropbox\PowerShell\> new-labvm -Name TestyTest -MediaId 2012R2_x64_Standard_EN_Eval -Verbose
VERBOSE: [22:35:08] Creating quick VM 'TestyTest' using media '2012R2_x64_Standard_EN_Eval'.
VERBOSE: [22:35:08] Setting Virtual Switch configuration 'Internal vSwitch'.
VERBOSE: [22:35:08] Checking DSC Resource 'xHyper-V\MSFT_xVMSwitch'.
VERBOSE: [22:35:08] Invoking command 'Test-VMSwitchTargetResource'.
VERBOSE: [22:35:09] Skipping command 'Set-VMSwitchTargetResource'.
VERBOSE: [22:35:09] (Re)setting VHDX configuration '2012R2_x64_Standard_EN_Eval'.
VERBOSE: [22:35:10] Removing VM 'TestyTest' snapshot 'VirtualEngineLab Baseline Snapshot'.
VERBOSE: [22:35:10] Checking DSC Resource 'xHyper-V\MSFT_xVHD'.
VERBOSE: [22:35:10] Invoking command 'Test-VHDTargetResource'.
VERBOSE: [22:35:10] Testing 'Test-VHDTargetResource' failed.
VERBOSE: [22:35:10] Invoking command 'Set-VHDTargetResource'.
VERBOSE: [22:35:11] Checking DSC Resource 'xHyper-V\MSFT_xVHD'.
VERBOSE: [22:35:11] Invoking command 'Test-VHDTargetResource'.
VERBOSE: [22:35:11] Testing 'Test-VHDTargetResource' failed.
VERBOSE: [22:35:11] Invoking command 'Set-VHDTargetResource'.
VERBOSE: [22:35:13] Setting VM configuration 'TestyTest'.
VERBOSE: [22:35:13] Checking DSC Resource 'xHyper-V\MSFT_xVMHyperV'.
CS! 'ProcessorCount' : '2'
CS! 'SwitchName' : 'System.String[]'
CS! 'SwitchName[]' : 'Internal vSwitch'
CS! 'MaximumMemory' : '1099511627776'
CS! 'SecureBoot' : 'True'
CS! 'MinimumMemory' : '536870912'
CS! 'Name' : 'TestyTest'
CS! 'StartupMemory' : '1073741824'
CS! 'VhdPath' : 'D:\TestLab\VM Disks\TestyTest.vhdx'
CS! 'Generation' : '2'
CS! 'RestartIfNeeded' : 'True'
VERBOSE: [22:35:13] Invoking command 'Test-VMTargetResource'.
VERBOSE: [22:35:14] Skipping command 'Set-VMTargetResource'.
VERBOSE: [22:35:14] Adding VM customizations.
VERBOSE: [22:35:15] Mounting disk image 'D:\TestLab\VM Disks\TestyTest.vhdx'.
VERBOSE: [22:35:16] Adding DSC resource modules to 'F:\Program Files\WindowsPowershell\Modules'.
VERBOSE: [22:35:16] Adding DSC resource 'RESONEAutomation' (v1.0.0).
VERBOSE: [22:35:16] Adding DSC resource 'RESONEServiceStore' (v1.0).
VERBOSE: [22:35:16] Adding DSC resource 'VirtualEngineBaseLab' (v1.2.0).
VERBOSE: [22:35:16] Adding DSC resource 'VirtualEngineTrainingLab' (v1.0.0).
VERBOSE: [22:35:16] Adding DSC resource 'xActiveDirectory' (v2.7.0.0).
VERBOSE: [22:35:17] Adding DSC resource 'xComputerManagement' (v1.3.0).
VERBOSE: [22:35:17] Adding DSC resource 'xCredSSP' (v1.0.1).
VERBOSE: [22:35:17] Adding DSC resource 'xDhcpServer' (v1.2).
VERBOSE: [22:35:17] Adding DSC resource 'xDnsServer' (v1.1).
VERBOSE: [22:35:17] Adding DSC resource 'xExchange' (v1.3.0.0).
VERBOSE: [22:35:18] Adding DSC resource 'xNetworking' (v2.5.0.0).
VERBOSE: [22:35:19] Adding DSC resource 'xPendingReboot' (v0.1.0.2).
VERBOSE: [22:35:19] Adding DSC resource 'xPSDesiredStateConfiguration' (v3.6.0.0).
VERBOSE: [22:35:19] Adding DSC resource 'xRemoteDesktopAdmin' (v1.1.0.0).
VERBOSE: [22:35:19] Adding DSC resource 'xSmbShare' (v1.1.0.0).
VERBOSE: [22:35:19] Setting local administrator password to 'P@ssw0rd'.
VERBOSE: [22:35:19] Adding Unattend file 'F:\Windows\System32\Sysprep\Unattend.xml'.
VERBOSE: [22:35:19] Adding BootStrap.ps1 file to 'F:\BootStrap'.
VERBOSE: [22:35:19] Creating directory 'F:\BootStrap'.
VERBOSE: [22:35:19] Adding SetupComplete.cmd to 'F:\Windows\Setup\Scripts'.
VERBOSE: [22:35:19] Creating directory 'F:\Windows\Setup\Scripts'.
VERBOSE: [22:35:19] Adding DSC file 'F:\BootStrap\localhost.mof'.
WARNING: [22:35:19] Cannot locate node 'D:\TestLab\Configurations\TestyTest.mof' file. No DSC configuration will be
applied. Ensure the DSC configuration has been run successfully.
VERBOSE: [22:35:19] Adding Client certificate 'F:\BootStrap\LabClient.pfx'.
VERBOSE: [22:35:19] Adding Root certificate 'F:\BootStrap\LabRoot.cer'.
VERBOSE: [22:35:19] Dismounting disk image 'D:\TestLab\VM Disks\TestyTest.vhdx'.
VERBOSE: [22:35:20] Creating baseline snapshot 'VirtualEngineLab Baseline Snapshot'.
Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
TestyTest Off 0 0 00:00:00 Operating normally 7.0 |
Still fails for me ... I'll see if I can find time to dig a little deeper into this issue Output of latest attempt: D:\SourceControl\Lab [Issue29]> New-LabVM -Name WIN10CLIENT -MediaId WIN10_x64_Enterprise_EN_Eval -Verbose
VERBOSE: [10:07:26] Creating quick VM 'WIN10CLIENT' using media 'WIN10_x64_Enterprise_EN_Eval'.
VERBOSE: [10:07:28] Setting Virtual Switch configuration 'External'.
VERBOSE: [10:07:28] Checking DSC Resource 'xHyper-V\MSFT_xVMSwitch'.
VERBOSE: [10:07:28] Importing bundled DSC Resource 'xHyper-V\MSFT_xVMSwitch'.
VERBOSE: [10:07:28] Invoking command 'Test-VMSwitchTargetResource'.
VERBOSE: [10:07:29] Skipping command 'Set-VMSwitchTargetResource'.
VERBOSE: [10:07:29] (Re)setting VHDX configuration 'WIN10_x64_Enterprise_EN_Eval'.
VERBOSE: [10:07:29] Checking DSC Resource 'xHyper-V\MSFT_xVHD'.
VERBOSE: [10:07:30] Importing bundled DSC Resource 'xHyper-V\MSFT_xVHD'.
VERBOSE: [10:07:30] Invoking command 'Test-VHDTargetResource'.
VERBOSE: [10:07:30] Testing 'Test-VHDTargetResource' failed.
VERBOSE: [10:07:30] Invoking command 'Set-VHDTargetResource'.
VERBOSE: [10:07:31] Setting VM configuration 'WIN10CLIENT'.
VERBOSE: [10:07:31] Checking DSC Resource 'xHyper-V\MSFT_xVMHyperV'.
VERBOSE: [10:07:31] Importing bundled DSC Resource 'xHyper-V\MSFT_xVMHyperV'.
CS! 'ProcessorCount' : '2'
CS! 'SwitchName' : 'System.String[]'
CS! 'SwitchName[]' : 'External'
CS! 'MaximumMemory' : '1099511627776'
CS! 'SecureBoot' : 'True'
CS! 'MinimumMemory' : '536870912'
CS! 'Name' : 'WIN10CLIENT'
CS! 'StartupMemory' : '2147483648'
CS! 'VhdPath' : 'D:\TestLab\VMVirtualHardDisks\WIN10CLIENT.vhdx'
CS! 'Generation' : '2'
CS! 'RestartIfNeeded' : 'True'
VERBOSE: [10:07:31] Invoking command 'Test-VMTargetResource'.
VERBOSE: [10:07:32] Testing 'Test-VMTargetResource' failed.
VERBOSE: [10:07:32] Invoking command 'Set-VMTargetResource'.
New-VM : Sequence contains more than one element
At D:\SourceControl\Lab\DSCResources\xHyper-V\DSCResources\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:291 char:2
1
+ $null = New-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.HyperV.PowerShell.Commands.NewVM
Set-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\DSCResources\xHyper-V\DSCResources\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:312 char:2
1
+ $null = Set-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Set-VM], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.SetVM
VERBOSE: [10:07:32] Adding VM customizations.
VERBOSE: [10:07:33] Mounting disk image 'D:\TestLab\VMVirtualHardDisks\WIN10CLIENT.vhdx'.
VERBOSE: [10:07:38] Adding DSC resource modules to 'J:\Program Files\WindowsPowershell\Modules'.
VERBOSE: [10:07:38] Adding DSC resource 'xActiveDirectory' (v2.6.0.0).
VERBOSE: [10:07:38] Adding DSC resource 'xComputerManagement' (v1.3.0).
VERBOSE: [10:07:38] Adding DSC resource 'xDhcpServer' (v1.2).
VERBOSE: [10:07:39] Adding DSC resource 'xDnsServer' (v1.1).
VERBOSE: [10:07:39] Adding DSC resource 'xNetworking' (v2.3.0.0).
VERBOSE: [10:07:39] Adding DSC resource 'xSmbShare' (v1.1.0.0).
VERBOSE: [10:07:39] Setting local administrator password to 'Passw0rd'.
VERBOSE: [10:07:39] Adding Unattend file 'J:\Windows\System32\Sysprep\Unattend.xml'.
VERBOSE: [10:07:39] Adding BootStrap.ps1 file to 'J:\BootStrap'.
VERBOSE: [10:07:39] Creating directory 'J:\BootStrap'.
VERBOSE: [10:07:39] Adding SetupComplete.cmd to 'J:\Windows\Setup\Scripts'.
VERBOSE: [10:07:39] Creating directory 'J:\Windows\Setup\Scripts'.
VERBOSE: [10:07:39] Adding DSC file 'J:\BootStrap\localhost.mof'.
WARNING: [10:07:39] Cannot locate node 'D:\TestLab\Configurations\WIN10CLIENT.mof' file. No DSC configura
tion will be applied. Ensure the DSC configuration has been run successfully.
VERBOSE: [10:07:39] Adding Client certificate 'J:\BootStrap\LabClient.pfx'.
VERBOSE: [10:07:39] Adding Root certificate 'J:\BootStrap\LabRoot.cer'.
VERBOSE: [10:07:39] Dismounting disk image 'D:\TestLab\VMVirtualHardDisks\WIN10CLIENT.vhdx'.
VERBOSE: [10:07:39] Creating baseline snapshot 'VirtualEngineLab Baseline Snapshot'.
Checkpoint-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\Src\LabVM.ps1:269 char:13
+ Checkpoint-VM -Name $Name -SnapshotName $snapshotName;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Checkpoint-VM], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.CheckpointVM
Get-VM : Hyper-V was unable to find a virtual machine with name "WIN10CLIENT".
At D:\SourceControl\Lab\Src\LabVM.ps1:281 char:36
+ Write-Output -InputObject (Get-VM -Name $Name);
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (WIN10CLIENT:String) [Get-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVM
D:\SourceControl\Lab [Issue29]> |
@csandfeld Can you change line 451 in LABVM.ps1 to a [System.String[]] type? Can you confirm that you only have one virtual switch called 'External'? |
You beat me to it ... I was just about to write that I found the bug ... the problem is that there are indeed two switches. I have been using a test configuratin script specifying a switch named "External", of type "External": @{
AllNodes = @(
@{
NodeName = '*'
InterfaceAlias = 'Ethernet'
CertificateFile = "$env:AllUsersProfile\VirtualEngineLab\Certificates\LabClient.cer"
Thumbprint = '599E0BDA95ADED538154DC9FA6DE94920424BCB1'
PSDscAllowDomainUser = $true
VirtualEngineLab_SwitchName = 'External'
}
,
@{
NodeName = 'SERVER2016TP4'
Role = 'CLIENT'
VirtualEngineLab_Media = '2016TP4_x64_Standard_EN'
}
)
NonNodeData = @{
VirtualEngineLab = @{
Network = @(
@{
Name = 'External'
Type = 'External'
NetAdapterName = 'Local Area Connection'
AllowManagementOS = $true
}
)
}
}
} When I invoke the New-LabVM function, it creates another switch named "External" of type "Internal". The same thing goes the other way around. If I clear my switches and run New-LabVM it works (and create a switch named "External" of type "Internal". If I then invoke Start-LabConfiguration with the config above, it creates a switch named "External" of type "External", and then fail to create the VM. |
On another note ... might it make sense to have a Remove-LabVM function as well ? |
OK - that'll cause a problem! The I see no problem with a Thanks again for all your help! |
I'm happy to help Iain. I think you have a great thing going here, and I can see great value for us for things such as qualifying Windows Server 2016. Keep up the good work. |
Removes VM switch creation from New-LabVM Removed VM resource injection for quick VMs Removes temporary debugging information Misc formatting changes
@csandfeld OK - give this one a whirl and let me know how you get on! |
Tried it, and it does generate a VM as expected ... but ... I cannot log on to the VM, as the local Administrator has been disabled. Tested with a Windows 10 VM. I have verified that this problems is not present, when deploying a Windows Server 2016 TP4 VM using the Start-LabConfiguration method. I will do a quick test of Server 2016 with the New-LabVM method as well, and see how that goes. |
Creating a Windows Server 2016 VM using New-LabVM worked as expected, and I was able to log on to the VM with the local administrator account afterwards. |
DOH! Yes – with the client OSes the local administrator account is disabled by default. The custom bootstrap enables this, but guess what, I disabled that functionality ☹. I tested with a server image! I’ll enable the custom bootstrapping for quick VMs. We’ll get there soon… |
Hehe ... well ... nice to know there is a logical explanation :) |
@csandfeld A happy New Year to you! I think this functionality is now in a good place for testing before I merge it in. As it's a fairly big change, would you mind having a look through the changes and trying the new Note: the client custom bootstrap that was in the |
And a happy new year to you @iainbrighton. I didn't get around to doing any work on this over the holidays (opted to relax with the family instead). Sounds as if you have been hard at work though. I will be happy to test/review your changes, and will get back to you on that as soon as possible. |
Testing on a host with 2016 TP4 and a clean Hyper-V install New-LabVM -Name WIN10CLIENT -MediaId WIN10_x64_Enterprise_EN_Eval -Verbose Resulted in the following error: VERBOSE: [8:25:54 AM] Invoking command 'Set-VMTargetResource'.
New-VM : Hyper-V was unable to find a virtual switch with name "Internal vSwitch".
At C:\Users\Administrator\Documents\WindowsPowerShell\Modules\VirtualEngineLab\DSCResources\xHyper-V\DSCResour
ces\MSFT_xVMHyperV\MSFT_xVMHyperV.psm1:291 char:21
+ $null = New-VM @parameters
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VM], VirtualizationException
+ FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.NewVM I don't recall if the switch has to be in place beforehand, or if it is supposed to create it. Could you enlighten me? |
Haha - the quick VM functionality won't create any virtual switches as the default switch type is 'Internal' - remember you already had a switch called "External" and it originally created an internal switch called "External"? I still think that this is an issue though as the default internal vSwitch should be there. Can you run |
Doing the same on a Windows 10 with the expected switch already in place works a treat. I can confirm that I can now logon with the local administrator account - this even with a new Windows 10 version added to CustomMedia.json, with the CustomBootStrap data copied over from the existing Windows 10 entry. |
I can confirm that after manually creating the 'Internal vSwitch' switch on my 2016 TP4 host, the VM was created successfully, and I can log on with the local administrator account here as well. I already did the Start-LabHostConfiguration bit (which installed Hyper-V etc.), but will remove the switch I just created, and try again. However, isn't the creation of switches supposed to be handled by Start-LabConfiguration as opposed to Start-LabHostConfiguration? |
I can confirm that Start-LabHostConfiguration does not create the default switch |
Good job! At least someone knows what the code does 😉 So the question is - do we always want to have the "default" virtual switch created? If not, we're probably good to go. Otherwise, I'll need to make an additional tweak... |
Not sure at this point. Will try to think that through on the drive home, and see if I can find time to get back to you later tonight if that's OK. |
No rush! Here's my thinking:
Thoughts? |
Assumptions (on my part):
If above is true is there any reason to treat a specified switch by another name different?
Alternatively a -SwitchType parameter could be added, accepting Private, Internal and External as values, and if External is specified, it could select the connected NIC with highest bandwidth for the switch. The value could be added to LabVmDefaults as well. This may be taking the "quick vm" functionality too far - I don't know. Thoughts? |
Conflicts: Src/LabVM.ps1 Src/LabVMDiskFile.ps1 en-US/about_Media.help.txt
In answer to your assumptions:
I don't know whether this changes any of your rationale? I think that trying to second-guess anything is a bad idea. |
Somehow it escaped my mind, that the Hyper-V configuration is done using a DSC resource. The fact that it will actually test the switch type, does not make much of a difference. I would still think that we could just create a switch, if the -SwitchName points to a switch that does not exist, and just use the same rationale as when creating the default switch (unless I'm am not seeing the full picture here - which is more than likely). Anyway ... when I first started working with VirtualEngineLab (on a relatively slow low-end PC), I constantly ran into problems where the Eval versions of Windows could not activate (as they need Internet access to activate and grant you those 90/180 days evaluation period). When they are not activated, they shut down after 1 hour, and when creating and powering on several VM's at once (the TLG scenario) it would start shutting down VM's before they completed their configuration. So I started creating setups with external switches instead, to allow those VM's to register, and complete their setup. So the question now I guess is, are we able (and do we want) to support the other switch types as well for the default switch (and possibly switches speciified with the -SwitchName parameter)? I don't know if this is straying to far from the original idea for the product? |
@csandfeld The only problem with using the DSC resource is that we have to specify a switch type when testing for its availability. To overcome this, we would need a separate bit of logic to determine whether a switch of any type, with a given name, exists or not. It's not the end-of-the-world as it's only a few lines of code. I was just trying to utilise the DSC resources due to their idempotent characteristics! I'll implement the switch name checking for the quick VM functionality. If it doesn't exist, we'll create an 'internal' virtual switch. I'm happy to discuss the merits of adding other switch types to the defaults, but that'll need to be logged as a separate issue for discussion! I hear you on the 'eval' media - it drives me nuts too! Why they don't have a 7 or 30-day grace period for activation is beyond me. This is why I would like to implement #44 (it's just a shame it's not yet available on Win 10 hosts). Could this be a better option?:
|
I agree... discussion about adding other switch types warrants its own topic. I think it would make sense to add an Eval suffix to the existing media ID's. And for Windows 10, perhaps even a build number, as currently they have eval versions available for both build 10240 and 10586. As a matter of fact, while testing the CustomBootStrap stuff the other day, I added the 10586 build to my custom media as follows: {
"Id": "WIN10_x64_Enterprise_EN_Eval_10586",
"Filename": "WIN10_x64_ENT_EN_Eval_10586.iso",
"Description": "Windows 10 64bit Enterprise English Evaluation build 10586",
"Architecture": "x64",
"ImageName": "Windows 10 Enterprise Evaluation Technical Preview",
"MediaType": "ISO",
"Uri": "http://download.microsoft.com/download/B/B/3/BB3611B6-9781-437F-A293-AB43B85C2190/10586.0.151029-1700.TH2_RELEASE_CLIENTENTERPRISEEVAL_OEMRET_X64FRE_EN-US.ISO",
"Checksum": "",
"CustomData": {
"WindowsOptionalFeature": ["NetFx3"],
"CustomBootstrap": [
"## Unattend.xml will set the Administrator password, but it won't enable the account on client OSes",
"NET USER Administrator /active:yes;",
"Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force;",
"## Kick-start PowerShell remoting on clients to permit applying DSC configurations",
"Enable-PSRemoting -SkipNetworkProfileCheck -Force;"
]
}, |
@csandfeld So leave the I certainly think that we need to do something with all these Win 10 builds. Don't they have code names like Threshold1 (TH1) and Threshold2 (TH2)? I think the next ones are Redstone? This all makes my head spin at the moment! 😕 |
@csandfeld Give the latest commit a go. If a switch does not exist, New-LabVM will now create an Internal virtual switch... You should be able to spin up a VM with a fresh/clean machine now (famous last words...) 😄 |
Oh sorry ... got that backwards. Somehow got into my head that they where originaly without the eval suffix. I can see pro's and con's of both scenarios, but at the end of the day, I think it makes sense to have the Media ID reflect the actual media. Personaly I would prefer having the ability to test with both Eval versions, VLK versions etc. Others might have different preferences. No matter what we go with here, I'm sure someone would have prefered it was different. It does bring me to another point though. You enabled adding media with Register-LabMedia, storing it in the CustomMedia.json, and removing media with Unregister-LabMedia (haven't tried removing though). So now we have media defined in two places. I'm guessing (haven't tried) that attempting to remove any of the default media would throw an error, and that trying to add media using an existing ID would as well? Anyway ... if a need would arise for someone to point a certain media ID from the default list of media to a different source, it could be implemented by writing that media to CustomMedia.json, and have that take preference. Might require a -Force or -Overwrite switch or something like that. |
Great ... I will try to find time to give that commit a spin tomorrow. |
@csandfeld Any update? Are you happy that this update is in state to merge in? |
Sorry mate, didn't get around to it. It's been a hectic couple of days, and I simply forgot all about it. Will have to get back to you. |
No rush. I'm pretty maxed out with training next week anyhow!
|
Checked the latest version of the Issue29 branch today, and it looks really good. |
Cool. Will merge that in at some point this week when u get a spare 10 mins!
|
Fixes #29 by adding New-LabVM cmdlet