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/Get-LabMofModule.ps1 b/Src/Private/Get-LabMofModule.ps1 index 6d12eec..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) { @@ -59,7 +60,7 @@ function Get-LabMofModule { } else { - Write-Warning -Message ($localized.CannotResolveMofModuleWarning -f $instanceLineNumber); + Write-Warning -Message ($localized.CannotResolveMofModuleWarning -f $path, $instanceLineNumber, $line); } $instanceLineNumber = $currentLineNumber; 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; diff --git a/en-US/Lability.Resources.psd1 b/en-US/Lability.Resources.psd1 index 8139e42..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 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.