From 7e7ca840c85b312b752f803e12e98e1c4920ca76 Mon Sep 17 00:00:00 2001 From: Katsuhiro Watanabe Date: Thu, 12 Jun 2025 16:28:13 +0900 Subject: [PATCH 1/5] Check HTTP Header before download in Save-WebFile.ps1 Prevent mistakenly downloading http contents indicating 404 error --- Public/Functions/Other/Save-WebFile.ps1 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Public/Functions/Other/Save-WebFile.ps1 b/Public/Functions/Other/Save-WebFile.ps1 index a8764a0f3..8ee8d9e5d 100644 --- a/Public/Functions/Other/Save-WebFile.ps1 +++ b/Public/Functions/Other/Save-WebFile.ps1 @@ -116,13 +116,17 @@ function Save-WebFile { else { Write-Verbose "cURL Source: $SourceUrl" Write-Verbose "Destination: $DestinationFullName" - - if ($host.name -match 'ConsoleHost') { - Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`"" - } - else { - #PowerShell ISE will display a NativeCommandError, so progress will not be displayed - $Quiet = Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`" 2>&1" + $Headers = Invoke-Expression "& curl.exe --head --silent --insecure --location --url `"$SourceUrl`"" + if ($Headers[0] -match "200.+OK") { + if ($host.name -match 'ConsoleHost') { + Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`"" + } + else { + #PowerShell ISE will display a NativeCommandError, so progress will not be displayed + $Quiet = Invoke-Expression "& curl.exe --insecure --location --output `"$DestinationFullName`" --url `"$SourceUrl`" 2>&1" + } + } else { + Write-Warning "Header status: $($headers[0])" } } #================================================= From 0894f8f3eeeebb8eee54ec30874ddf30158d8895 Mon Sep 17 00:00:00 2001 From: Katsuhiro Watanabe Date: Thu, 12 Jun 2025 16:35:37 +0900 Subject: [PATCH 2/5] Import offline driver catalog in OSDCloud.DriverPack.ps1 --- Public/OSDCloudDriverPack/OSDCloud.DriverPack.ps1 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Public/OSDCloudDriverPack/OSDCloud.DriverPack.ps1 b/Public/OSDCloudDriverPack/OSDCloud.DriverPack.ps1 index 5576d6e3f..edb01c7a9 100644 --- a/Public/OSDCloudDriverPack/OSDCloud.DriverPack.ps1 +++ b/Public/OSDCloudDriverPack/OSDCloud.DriverPack.ps1 @@ -67,7 +67,17 @@ function Get-OSDCloudDriverPacks { #> [CmdletBinding()] param () - $Results = Import-Clixml -Path "$(Get-OSDModulePath)\cache\driverpack-catalogs\build-driverpacks.xml" + $DriverCatalogXML = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object { + Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "build-driverpacks.xml" -File -Force -Recurse -ErrorAction Ignore + } + if ($DriverCatalogXML) { + foreach ($Item in $DriverCatalogXML) { + Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)." + $Results = Import-Clixml -Path $Item.FullName + } + } else { + $Results = Import-Clixml -Path "$(Get-OSDModulePath)\cache\driverpack-catalogs\build-driverpacks.xml" + } $Results } function Save-OSDCloudDriverPack { From b143fcc7fab4d8b428207d0715ca7158346cedd5 Mon Sep 17 00:00:00 2001 From: Katsuhiro Watanabe Date: Thu, 12 Jun 2025 16:37:18 +0900 Subject: [PATCH 3/5] Import offline OS catalog in Get-OSDCloudOperatingSystems.ps1 --- .../OSDCloudTS/Get-OSDCloudOperatingSystems.ps1 | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Public/OSDCloudTS/Get-OSDCloudOperatingSystems.ps1 b/Public/OSDCloudTS/Get-OSDCloudOperatingSystems.ps1 index 377e63705..3973b801f 100644 --- a/Public/OSDCloudTS/Get-OSDCloudOperatingSystems.ps1 +++ b/Public/OSDCloudTS/Get-OSDCloudOperatingSystems.ps1 @@ -16,12 +16,18 @@ function Get-OSDCloudOperatingSystems { [System.String] $OSArch = 'x64' ) - $FullResults = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystems.json" | ConvertFrom-Json - if ($OSArch -eq 'x64'){ - $Results = $FullResults | Where-Object {$_.Architecture -eq "x64"} + $OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object { + Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystems.json" -File -Force -Recurse -ErrorAction Ignore } - elseif ($OSArch -eq "arm64"){ - $Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsARM64.json" | ConvertFrom-Json + if ($OfflineCatalog) { + foreach ($Item in $OfflineCatalog) { + Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)." + $FullResults = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop" + } + $Results = $FullResults | Where-Object {$_.Architecture -eq $OSArch} + } else { + $FullResults = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystems.json" | ConvertFrom-Json + $Results = $FullResults | Where-Object {$_.Architecture -eq $OSArch} } $Results } \ No newline at end of file From 49c6d9957a0ba4c646a8ab62641fffae393fbf54 Mon Sep 17 00:00:00 2001 From: Katsuhiro Watanabe Date: Thu, 12 Jun 2025 16:38:18 +0900 Subject: [PATCH 4/5] Import offline OS catalog in Get-OSDCloudOperatingSystemsIndexMap.ps1 Fix bug in the previous version. Use UTF8 for tentative workaround. --- .../Get-OSDCloudOperatingSystemsIndexMap.ps1 | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexMap.ps1 b/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexMap.ps1 index 8897ee096..28dbfa13d 100644 --- a/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexMap.ps1 +++ b/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexMap.ps1 @@ -21,9 +21,19 @@ function Get-OSDCloudOperatingSystemsIndexMap { $OSArch = 'x64' ) - $indexMapPath = "$(Get-OSDModulePath)\cache\archive-cloudoperatingindexmap\CloudOperatingIndexMap.json" - $Results = Get-Content -Path $indexMapPath | ConvertFrom-Json + $OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object { + Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingIndexMap.json" -File -Force -Recurse -ErrorAction Ignore + } + if ($OfflineCatalog) { + foreach ($Item in $OfflineCatalog) { + Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)." + $indexMapPath = (Get-Item -Path "$($Item.FullName)").FullName + } + } else { + $indexMapPath = "$(Get-OSDCachePath)\archive-cloudoperatingindexmap\CloudOperatingIndexMap.json" + } + $Results = Get-Content -Path $indexMapPath -Encoding UTF8 | ConvertFrom-Json # as of OSD 25.6.10.1 encoding of the json is UTF8 $Results = $Results | Where-Object { $_.Architecture -eq $OSArch } return $Results -} \ No newline at end of file +} From 1f090f080f92f15a984166721c62b432ff64f25b Mon Sep 17 00:00:00 2001 From: Katsuhiro Watanabe Date: Thu, 12 Jun 2025 16:40:06 +0900 Subject: [PATCH 5/5] Import offline OS catalog in Get-OSDCloudOperatingSystemsIndexes.ps1 --- .../Get-OSDCloudOperatingSystemsIndexes.ps1 | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexes.ps1 b/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexes.ps1 index 5ca1b0f67..37c73f9cb 100644 --- a/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexes.ps1 +++ b/Public/OSDCloudTS/Get-OSDCloudOperatingSystemsIndexes.ps1 @@ -19,10 +19,30 @@ function Get-OSDCloudOperatingSystemsIndexes { ) if ($OSArch -eq 'x64') { - $Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsIndexes.json" | ConvertFrom-Json + $OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object { + Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystemsIndexes.json" -File -Force -Recurse -ErrorAction Ignore + } + if ($OfflineCatalog) { + foreach ($Item in $OfflineCatalog) { + Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)." + $Results = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop" + } + } else { + $Results = Get-Content -Path "$(Get-OSDCachePath)\archive-cloudoperatingsystems\CloudOperatingSystemsIndexes.json" | ConvertFrom-Json + } } elseif ($OSArch -eq "ARM64") { - $Results = Get-Content -Path "$(Get-OSDModulePath)\cache\archive-cloudoperatingsystems\CloudOperatingSystemsARM64Indexes.json" | ConvertFrom-Json + $OfflineCatalog = Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Name -ne 'C'} | ForEach-Object { + Get-ChildItem "$($_.Root)OSDCloud\Catalogs" -Include "CloudOperatingSystemsARM64Indexes.json" -File -Force -Recurse -ErrorAction Ignore + } + if ($OfflineCatalog) { + foreach ($Item in $OfflineCatalog) { + Write-Warning "$($Item.FullName) is imported instead of the cache under $(Get-OSDModulePath)." + $Results = Get-Content -Path "$($Item.FullName)" | ConvertFrom-Json -ErrorAction "Stop" + } + } else { + $Results = Get-Content -Path "$(Get-OSDCachePath)\archive-cloudoperatingsystems\CloudOperatingSystemsARM64Indexes.json" | ConvertFrom-Json + } } return $Results