LabBuilder icon indicating copy to clipboard operation
LabBuilder copied to clipboard

Bug: New-Lab -ConfigPath parameter doesn't check if entry contains .xml

Open DennisL68 opened this issue 4 years ago • 0 comments

Verison of PowerShell: 
$PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17763  1007

PowerShell host:
Console

Operating system:
Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, ServicePackMajorVersion, OSArchitecture, WindowsDirectory


Caption                 : Microsoft Windows Server 2019 Standard
Version                 : 10.0.17763
ServicePackMajorVersion : 0
OSArchitecture          : 64-bit
WindowsDirectory        : C:\Windows


Version of LabBuilder:
PS C:\Windows\system32> Get-Module -Name LabBuilder -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.5.105  LabBuilder                          {Get-LabResourceModule, Initialize-LabResourceModule, Get-...

Creating a new lab specifying only a folder path will output a lot of errors.

C:\Windows\system32> New-Lab -Name TestLab -LabPath c:\users\public\TestLab -ConfigPath C:\users\Public\TestLab
Exception calling "Save" with "1" argument(s): "Access to the path 'C:\users\Public\TestLab' is denied."
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:10056 char:5
+     $Lab.Save($ConfigPath)
+     ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Get-Content : Access to the path 'C:\users\Public\TestLab' is denied.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6174 char:16
+     $content = Get-Content -Path $ConfigPath -Raw
+                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (C:\users\Public\TestLab:String) [Get-Content], UnauthorizedAccessExce
   ption
    + FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetContentCommand

New-LabException : Configuration file C:\users\Public\TestLab is empty.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6184 char:9
+         New-LabException @exceptionParameters
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-LabException], Exception
    + FullyQualifiedErrorId : ConfigurationFileEmptyError,New-LabException

Assert-LabValidConfigurationXMLSchema : Exception calling "Create" with "2" argument(s): "Access to the path
'C:\users\Public\TestLab' is denied."
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6190 char:9
+         Assert-LabValidConfigurationXMLSchema `
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Assert-LabValidConfigurationXMLSchema], MethodInvocationException
    + FullyQualifiedErrorId : UnauthorizedAccessException,Assert-LabValidConfigurationXMLSchema

Exception calling "LoadXml" with "1" argument(s): "Root element is missing."
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6198 char:5
+     $lab.LoadXML($content)
+     ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6232 char:5
+     $lab.labbuilderconfig.settings.setattribute('fullconfigpath', $fu ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6237 char:9
+         $lab.labbuilderconfig.settings.SetAttribute('labpath', $labPa ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6254 char:5
+     $lab.labbuilderconfig.settings.setattribute('vhdparentpathfull',  ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6266 char:5
+     $lab.labbuilderconfig.settings.setattribute('dsclibrarypathfull', ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\LabBuilder\1.1.0\LabBuilder.psm1:6278 char:5
+     $lab.labbuilderconfig.settings.setattribute('resourcepathfull', $ ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull



NodeType           : Document
ParentNode         :
DocumentType       :
Implementation     : System.Xml.XmlImplementation
Name               : #document
LocalName          : #document
DocumentElement    :
OwnerDocument      :
Schemas            : System.Xml.Schema.XmlSchemaSet
XmlResolver        :
NameTable          : System.Xml.NameTable
PreserveWhitespace : True
IsReadOnly         : False
InnerText          :
InnerXml           :
SchemaInfo         : System.Xml.Schema.XmlSchemaInfo
BaseURI            :
Value              :
ChildNodes         : {}
PreviousSibling    :
NextSibling        :
Attributes         :
FirstChild         :
LastChild          :
HasChildNodes      : False
NamespaceURI       :
Prefix             :
OuterXml           :
PreviousText       :

DennisL68 avatar Oct 14 '20 11:10 DennisL68