Skip to content
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

[Bug]: Error when attempting to add a VM with Add-LabMachineDefinition #1572

Open
Stephanevg opened this issue Oct 13, 2023 · 4 comments
Open
Assignees

Comments

@Stephanevg
Copy link

Stephanevg commented Oct 13, 2023

Description

Hi,

I do have a an existing lab which a provisioned a few days back. I wanted to add an additional VM to it (a WIN11 machine) to do tests on that specific OS.

When I try, to use Add-LabMachineDefinition I get the following message back.

PS C:\Users\svang> Add-LabMachineDefinition -Name "WIN1101" -Memory 1GB -OperatingSystem 'Windows 11 Pro' -Verbose
VERBOSE: [15:31:58][Write-LogFunctionEntry] Add-LabMachineDefinition Entering... (Name=WIN1101,Memory=1073741824,OperatingSystem=Windows 11 Pro,Verbose=True)
VERBOSE: [15:31:58][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [15:31:58][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [15:31:58][Write-ScreenInfo] Adding Hyper-V machine definition 'WIN1101'
VERBOSE: [15:31:58][Write-ScreenInfo] 15:31:58|00:52:36|00:00:00.000|     - Adding Hyper-V machine definition 'WIN1101'
15:31:58|00:52:36|00:00:00.000|     - Adding Hyper-V machine definition 'WIN1101'
VERBOSE: [15:31:58][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [15:31:58][Write-LogFunctionEntry] Get-LabDefinition Entering... )
Exception: Lab is already imported. Please create a new lab definition by calling New-LabDefinition before adding machines
PS C:\Users\svang>

When I launch New-LabDefintion it actually proposes to create a new lab. Which is not what I want, and I specifically do not want to lose my existing lab. I would like to ADD a vm to it, and not add a second lab next it.

The documentation does not indicates that that is a mandatory step, and it would make sense to me that we could add VM's to an existing loaded (or not) lab.

Steps to reproduce the issue

Get-Lab -list
BasementLab

#Returns my labName -> BasementLab

Import-Lab -Name BasementLab -PassThru

#returns

<#
15:40:08|01:00:46|00:00:00.000|       - Validating lab definition
15:40:10|01:00:48|00:00:01.644|         - Success

    Lab Name: BasementLab (HyperV)

        LabFilePath: C:\ProgramData\AutomatedLab\Labs\BasementLab\Lab.xml
        VM Path: C:\AutomatedLab-VMs

        Machines: 3
        Domains:  1
        Networks: 1

15:40:10|01:00:48|00:00:01.698|       - Lab 'BasementLab' hosted on 'HyperV' imported with 3 machines
#>

#If i try from a fresh powershell console. I get this.

Add-LabMachineDefinition -Name "WIN1101" -Memory 1GB -OperatingSystem 'Windows 11 Pro' -Verbose
<#
PowerShell 7.3.8
PS C:\Users\svang> Add-LabMachineDefinition -Name "WIN1101" -Memory 1GB -OperatingSystem 'Windows 11 Pro' -Verbose
WARNING: (544,45): warning CS0168: The variable 'e' is declared but never used
                        catch (COMException e)
                                            ^

VERBOSE: [15:41:12][Write-LogFunctionEntry] Add-LabMachineDefinition Entering... (Name=WIN1101,Memory=1073741824,OperatingSystem=Windows 11 Pro,Verbose=True)
VERBOSE: [15:41:12][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [15:41:12][Write-ScreenInfo] Adding Hyper-V machine definition 'WIN1101'
VERBOSE: [15:41:12][Write-ScreenInfo] 15:41:12|00:00:00|00:00:00.004| Adding Hyper-V machine definition 'WIN1101'
15:41:12|00:00:00|00:00:00.004| Adding Hyper-V machine definition 'WIN1101'
VERBOSE: [15:41:12][Write-LogFunctionEntry] Get-LabDefinition Entering... )
Exception: Please create a lab definition by calling New-LabDefinition before adding machines
#>

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.8
PSEdition                      Core
GitCommitId                    7.3.8
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

AutomatedLab Version

Name                      Version
----                      -------
AutomatedLab              5.49.0
AutomatedLab.Common       2.3.17
AutomatedLab.Recipe       5.49.0
AutomatedLab.Ships        5.49.0
AutomatedLabCore          5.49.0
AutomatedLabDefinition    5.49.0
AutomatedLabNotifications 5.49.0
AutomatedLabTest          5.49.0
AutomatedLabUnattended    5.49.0
AutomatedLabWorker        5.49.0
@Stephanevg
Copy link
Author

I tried with another ISO as well, I still get the same error:

PS C:\Users\svang> Get-Lab

    Lab Name: BasementLab (HyperV)

        LabFilePath: C:\ProgramData\AutomatedLab\Labs\BasementLab\Lab.xml
        VM Path: C:\AutomatedLab-VMs

        Machines: 3
        Domains:  1
        Networks: 1


PS C:\Users\svang> Add-LabMachineDefinition -Name "WIN10" -Memory 1GB -OperatingSystem 'Windows 10 Enterprise Evaluation' -Verbose
VERBOSE: [10:03:48][Write-LogFunctionEntry] Add-LabMachineDefinition Entering... (Name=WIN10,Memory=1073741824,OperatingSystem=Windows 10 Enterprise Evaluation,Verbose=True)
VERBOSE: [10:03:48][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [10:03:48][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [10:03:48][Write-ScreenInfo] Adding Hyper-V machine definition 'WIN10'
VERBOSE: [10:03:48][Write-ScreenInfo] 10:03:48|00:11:48|00:00:00.000| - Adding Hyper-V machine definition 'WIN10'
10:03:48|00:11:48|00:00:00.000| - Adding Hyper-V machine definition 'WIN10'
VERBOSE: [10:03:48][Write-LogFunctionEntry] Get-LabDefinition Entering... )
VERBOSE: [10:03:48][Write-LogFunctionEntry] Get-LabDefinition Entering... )
Exception: Lab is already imported. Please create a new lab definition by calling New-LabDefinition before adding machines

Using the New-LabDefinition actually goes and creates another lab. I tried giving it the same name hoping it would add the machine to the already existing one, but unfortunatly it removed the previous lab, and created an empty one. I managed to get it back as my original one was located at C:\ProgramData\AutomatedLab\Labs\BasementLab\Lab.xml

What would the solution be? Is this not supported ? Do I have to create a new lab from scratch?

@raandree maybe you can point me in the right direction? I am a bit blocked unfortunatley :(

@dkettman
Copy link

@Stephanevg

Did you get anywhere with this? I am running into the same problem working to get portable training environments for my colleagues.

@Stephanevg
Copy link
Author

hey @dkettman I actually did.

You actually should use import-LabDefinition instead of import-Lab

Import-LabDefinition -Name BasementLab
Add-LabMachineDefinition -Name win10
Install-Lab

@raandree raandree self-assigned this Dec 23, 2023
@raandree
Copy link
Member

Sorry for my late answer. @Stephanevg, is the issue solved for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants