From 5300caccb816458027e79bbb58ecf5c0eb9b8f0f Mon Sep 17 00:00:00 2001 From: Cody Konior Date: Wed, 17 Jul 2024 11:26:20 +0800 Subject: [PATCH 1/5] Add mof debugging info --- en-US/Lability.Resources.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en-US/Lability.Resources.psd1 b/en-US/Lability.Resources.psd1 index 8139e42..626d630 100644 --- a/en-US/Lability.Resources.psd1 +++ b/en-US/Lability.Resources.psd1 @@ -202,7 +202,7 @@ ConvertFrom-StringData -StringData @' ExplicitOutputPathWarning = Parameter 'OutputPath' was explicitly passed and is also defined in the 'ConfigurationParameters' hashtable. Using OutputPath '{0}'. ExplicitConfigurationDataWarning = Parameter 'ConfigurationData' was explicitly passed and is also defined in the 'ConfigurationParameters' hashtable. Using ConfigurationData '{0}'. SkippingMetaConfigurationWarning = Skipping meta configuration file '{0}'. - CannotResolveMofModuleWarning = Cannot resolve MOF module name and/or version of the instance defined at line {0}. + CannotResolveMofModuleWarning = Cannot resolve MOF module name and/or version of the instance defined in file {0} at line {1} as '{2}'. ModuleUsingMinimumVersionWarning = Module '{0}' definition is configured with the 'MinimumVersion' property. It is recommended to use the 'RequiredVersion' property instead. ModuleMissingRequiredVerWarning = Module '{0}' definition is missing 'RequiredVersion' property. It recommended to use the 'RequiredVersion' property. MofModuleVersionMismatchWarning = Module '{0}' version mismatch. The version '{1}' defined in the .mof file does not match the version '{2}' defined in the Lability configuration file. From f0bb4a049e0d8086e24e82387d02c7f732f012b8 Mon Sep 17 00:00:00 2001 From: Cody Konior Date: Wed, 17 Jul 2024 11:27:36 +0800 Subject: [PATCH 2/5] Add mof debugging info --- Src/Private/Get-LabMofModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/Private/Get-LabMofModule.ps1 b/Src/Private/Get-LabMofModule.ps1 index 6d12eec..d6be50b 100644 --- a/Src/Private/Get-LabMofModule.ps1 +++ b/Src/Private/Get-LabMofModule.ps1 @@ -59,7 +59,7 @@ function Get-LabMofModule { } else { - Write-Warning -Message ($localized.CannotResolveMofModuleWarning -f $instanceLineNumber); + Write-Warning -Message ($localized.CannotResolveMofModuleWarning -f $path, $instanceLineNumber, $line); } $instanceLineNumber = $currentLineNumber; From a898448c4b57025f858fc3ac107c34c99a2efd5c Mon Sep 17 00:00:00 2001 From: Cody Konior Date: Wed, 17 Jul 2024 11:29:31 +0800 Subject: [PATCH 3/5] Add quotes --- en-US/Lability.Resources.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en-US/Lability.Resources.psd1 b/en-US/Lability.Resources.psd1 index 626d630..dbad985 100644 --- a/en-US/Lability.Resources.psd1 +++ b/en-US/Lability.Resources.psd1 @@ -202,7 +202,7 @@ ConvertFrom-StringData -StringData @' ExplicitOutputPathWarning = Parameter 'OutputPath' was explicitly passed and is also defined in the 'ConfigurationParameters' hashtable. Using OutputPath '{0}'. ExplicitConfigurationDataWarning = Parameter 'ConfigurationData' was explicitly passed and is also defined in the 'ConfigurationParameters' hashtable. Using ConfigurationData '{0}'. SkippingMetaConfigurationWarning = Skipping meta configuration file '{0}'. - CannotResolveMofModuleWarning = Cannot resolve MOF module name and/or version of the instance defined in file {0} at line {1} as '{2}'. + CannotResolveMofModuleWarning = Cannot resolve MOF module name and/or version of the instance defined in file '{0}' at line {1} as '{2}'. ModuleUsingMinimumVersionWarning = Module '{0}' definition is configured with the 'MinimumVersion' property. It is recommended to use the 'RequiredVersion' property instead. ModuleMissingRequiredVerWarning = Module '{0}' definition is missing 'RequiredVersion' property. It recommended to use the 'RequiredVersion' property. MofModuleVersionMismatchWarning = Module '{0}' version mismatch. The version '{1}' defined in the .mof file does not match the version '{2}' defined in the Lability configuration file. From 7eae5482c983e2171f89a596183fa49e600636e2 Mon Sep 17 00:00:00 2001 From: Cody Konior Date: Wed, 17 Jul 2024 12:57:48 +0800 Subject: [PATCH 4/5] Stop mof warning on SqlServerDsc --- Src/Private/Get-LabMofModule.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Private/Get-LabMofModule.ps1 b/Src/Private/Get-LabMofModule.ps1 index d6be50b..6826430 100644 --- a/Src/Private/Get-LabMofModule.ps1 +++ b/Src/Private/Get-LabMofModule.ps1 @@ -44,9 +44,10 @@ function Get-LabMofModule { foreach ($line in [System.IO.File]::ReadLines($Path)) { $currentLineNumber++; - if ($line -match '^instance of (?!MSFT_Credential|MSFT_xWebBindingInformation)') { + if ($line -match '^instance of (?!MSFT_Credential|MSFT_xWebBindingInformation|ServerPermission)') { ## Ignore MSFT_Credential and MSFT_xWebBindingInformation types. There may be - ## other types that need suppressing, but they'll be resource specific + ## other types that need suppressing, but they'll be resource specific, like + ## ServerPermission is part of SqlServerDsc if ($null -eq $currentModule) { From fc360f60b1a4804ae3cc5a6254789c87c1b8f461 Mon Sep 17 00:00:00 2001 From: Cody Konior Date: Mon, 29 Jul 2024 17:17:20 +0800 Subject: [PATCH 5/5] Change UseFolder to DownloadToFolder --- Src/Private/Expand-LabResource.ps1 | 20 ++++++++++++++++--- .../Get-LabHostDscConfigurationPath.ps1 | 1 - Src/Private/Invoke-LabMediaImageDownload.ps1 | 2 +- Src/Private/New-LabMedia.ps1 | 8 ++++++++ Src/Public/Invoke-LabResourceDownload.ps1 | 8 +++++++- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Src/Private/Expand-LabResource.ps1 b/Src/Private/Expand-LabResource.ps1 index 7575d48..fff6ecd 100644 --- a/Src/Private/Expand-LabResource.ps1 +++ b/Src/Private/Expand-LabResource.ps1 @@ -55,8 +55,14 @@ function Expand-LabResource { $resourceSourcePath = Join-Path $resourcePath -ChildPath $resource.Id; if ($resource.Filename) { - - $resourceSourcePath = Join-Path $resourcePath -ChildPath $resource.Filename; + + if ($resource.DownloadToFolder -and $resource.Expand) { + $resourceSourcePath = Join-Path $resourcePath -ChildPath (Join-Path -Path $resource.Id -ChildPath $resource.Filename) + } elseif ($resource.DownloadToFolder) { + $resourceSourcePath = Join-Path $resourcePath -ChildPath $resource.Id + } else { + $resourceSourcePath = Join-Path $resourcePath -ChildPath $resource.Filename; + } if ($resource.IsLocal) { $resourceSourcePath = Resolve-Path -Path $resource.Filename; @@ -113,8 +119,9 @@ function Expand-LabResource { switch ([System.IO.Path]::GetExtension($resourceSourcePath)) { '.iso' { - + Write-Verbose "Expand [$($resourceItem.FullName)] to [$resourceDestinationPath]" Expand-LabIso -Path $resourceItem.FullName -DestinationPath $resourceDestinationPath; + break; } '.zip' { @@ -126,6 +133,13 @@ function Expand-LabResource { Verbose = $false; } [ref] $null = Expand-ZipArchive @expandZipArchiveParams; + break; + } + + { $resource.DownloadToFolder } { + Write-Verbose "Copy [$resourceSourcePath] from [$($resourceItem.FullName)] to [$resourceDestinationPath]" + Copy-Item -Path $resourceItem.FullName $resourceDestinationPath -Recurse + break; } Default { diff --git a/Src/Private/Get-LabHostDscConfigurationPath.ps1 b/Src/Private/Get-LabHostDscConfigurationPath.ps1 index 63765b7..8e83a85 100644 --- a/Src/Private/Get-LabHostDscConfigurationPath.ps1 +++ b/Src/Private/Get-LabHostDscConfigurationPath.ps1 @@ -13,4 +13,3 @@ function Get-LabHostDscConfigurationPath { } #end process } #end function Get-LabHostDscConfigurationPath - diff --git a/Src/Private/Invoke-LabMediaImageDownload.ps1 b/Src/Private/Invoke-LabMediaImageDownload.ps1 index 3e482d7..1ab71f7 100644 --- a/Src/Private/Invoke-LabMediaImageDownload.ps1 +++ b/Src/Private/Invoke-LabMediaImageDownload.ps1 @@ -24,7 +24,7 @@ function Invoke-LabMediaImageDownload { $hostDefaults = Get-ConfigurationData -Configuration Host; $invokeResourceDownloadParams = @{ - DestinationPath = Join-Path -Path $hostDefaults.IsoPath -ChildPath $media.Filename; + DestinationPath = if ($media.DownloadToFolder) { Join-Path -Path $hostDefaults.IsoPath -ChildPath (Join-Path -Path $media.Id -ChildPath $media.Filename); } else { Join-Path -Path $hostDefaults.IsoPath -ChildPath $media.Filename; } Uri = $media.Uri; Checksum = $media.Checksum; } diff --git a/Src/Private/New-LabMedia.ps1 b/Src/Private/New-LabMedia.ps1 index 74e9961..0c0b4fb 100644 --- a/Src/Private/New-LabMedia.ps1 +++ b/Src/Private/New-LabMedia.ps1 @@ -25,6 +25,12 @@ function New-LabMedia { [ValidateSet('x86','x64')] [System.String] $Architecture = $(throw ($localized.MissingParameterError -f 'Architecture')), + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $DownloadToFolder, + + [Parameter(ValueFromPipelineByPropertyName)] + [System.Boolean] $CopyToFolder, + [Parameter(ValueFromPipelineByPropertyName)] [System.String] $ImageName = '', @@ -80,6 +86,8 @@ function New-LabMedia { Filename = $Filename; Description = $Description; Architecture = $Architecture; + DownloadToFolder = $DownloadToFolder; + CopyToFolder = $CopyToFolder; ImageName = $ImageName; MediaType = $MediaType; OperatingSystem = $OperatingSystem; diff --git a/Src/Public/Invoke-LabResourceDownload.ps1 b/Src/Public/Invoke-LabResourceDownload.ps1 index bf05e10..ab563ba 100644 --- a/Src/Public/Invoke-LabResourceDownload.ps1 +++ b/Src/Public/Invoke-LabResourceDownload.ps1 @@ -149,7 +149,13 @@ function Invoke-LabResourceDownload { if (($null -eq $resource.IsLocal) -or ($resource.IsLocal -eq $false)) { $fileName = $resource.Id; - if ($resource.Filename) { $fileName = $resource.Filename; } + if ($resource.Filename) { + if ($resource.DownloadToFolder) { + $fileName = $fileName + "\" + $resource.Filename + } else { + $fileName = $resource.Filename + } + } $resourceDestinationPath = Join-Path -Path $DestinationPath -ChildPath $fileName; $invokeResourceDownloadParams = @{ DestinationPath = $resourceDestinationPath;